Skip to content

Commit

Permalink
Use src layout (#2311)
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <[email protected]>
  • Loading branch information
gaborbernat authored Feb 7, 2025
1 parent dea7b4b commit 19134de
Show file tree
Hide file tree
Showing 58 changed files with 81 additions and 38 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,8 @@ jobs:
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install hatch
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
- name: Build package to generate version
run: uv build --python 3.13 --python-preference only-managed --wheel . --out-dir dist
- name: Setup coverage tool
run: tox run -e coverage --notest
env:
Expand Down
46 changes: 25 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ dev = [
{ include-group = "type" },
]
test = [
"diff-cover>=7.7",
"freezegun",
"pytest>=6.1",
"pytest>=8.3.4",
Expand All @@ -85,6 +84,7 @@ test = [
"pytest-mock>=3.14",
"pytest-xdist>=3.3.1",
"setuptools; python_version<'3.9'",
{ include-group = "coverage" },
]
type = [
"pyright>=1.1.393",
Expand All @@ -107,14 +107,15 @@ isort4-pydantic15 = [ "isort[pyproject]==4.3.21", "pydantic==1.5.1" ]
fix = [ "pre-commit>=3.5" ]
pkg-meta = [ "check-wheel-contents>=0.6.1", "twine>=6.1", "uv>=0.5.22" ]
coverage = [
"covdefaults>=2.3",
"coverage[toml]>=7.6.1",
"diff-cover>=7.7",
]

[tool.hatch]
build.dev-mode-dirs = [ "." ]
build.dev-mode-dirs = [ "src" ]
build.targets.sdist.include = [
"/datamodel_code_generator",
"/src",
"/tests",
]
version.source = "vcs"
Expand Down Expand Up @@ -151,25 +152,28 @@ filterwarnings = [
norecursedirs = "tests/data/*"

[tool.coverage]
run.source = [ "datamodel_code_generator" ]
run.branch = true
run.omit = [ "scripts/*", "tests/*" ]
report.ignore_errors = true
report.exclude_lines = [
"if self.debug:",
"pragma: no cover",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"if not TYPE_CHECKING:",
]
html.skip_covered = false
html.show_contexts = false
paths.source = [
"datamodel_code_generator",
".tox*/*/lib/python*/site-packages/datamodel_code_generator",
".tox*\\*\\Lib\\site-packages\\datamodel_code_generator",
"*/datamodel_code_generator",
"*\\datamodel_code_generator",
]
"src",
".tox*/*/lib/python*/site-packages",
".tox*\\*\\Lib\\site-packages",
"*/src",
"*\\src",
]
paths.other = [
".",
"*/datamodel-code-generator",
"*\\datamodel-code-generator",
]
run.dynamic_context = "none"
run.omit = [ "tests/data/*" ]
report.fail_under = 94
run.parallel = true
run.plugins = [
"covdefaults",
]
covdefaults.subtract_omit = "*/__main__.py"

[tool.pyright]
reportPrivateImportUsage = false
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 9 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
requires =
tox>=4.24.1
tox-uv>=1.12
tox-uv>=1.23
env_list =
fix
3.13
Expand Down Expand Up @@ -33,8 +33,9 @@ set_env =
COVERAGE_FILE = {work_dir}/.coverage.{env_name}
commands =
pytest {posargs: \
--cov datamodel_code_generator --cov {tox_root}{/}tests \
--cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \
-p no:codspeed --benchmark-disable \
--cov {env_site_packages_dir}{/}datamodel_code_generator --cov {tox_root}{/}tests \
--cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered \
--cov-report html:{env_tmp_dir}{/}htmlcov \
--cov-report xml:{env:COVERAGE_XML:{work_dir}{/}coverage.{env_name}.xml} \
--junitxml {work_dir}{/}junit.{env_name}.xml \
Expand Down Expand Up @@ -72,13 +73,13 @@ parallel_show_output = true
pass_env =
DIFF_AGAINST
set_env =
COVERAGE_FILE = {toxworkdir}/.coverage
COVERAGE_FILE = {work_dir}/.coverage
commands =
coverage combine
coverage report --skip-covered --show-missing
coverage xml -o {toxworkdir}/coverage.xml
coverage html -d {toxworkdir}/htmlcov
diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml
coverage xml -o {work_dir}/coverage.xml
coverage html -d {work_dir}/htmlcov
diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {work_dir}/coverage.xml
depends =
3.13
3.12
Expand All @@ -103,7 +104,7 @@ dependency_groups = pkg-meta
[testenv:type]
description = run type check on code base
commands =
pyright datamodel_code_generator
pyright src
dependency_groups = type

[testenv:docs]
Expand Down
48 changes: 46 additions & 2 deletions uv.lock

Large diffs are not rendered by default.

0 comments on commit 19134de

Please sign in to comment.