Skip to content

Commit

Permalink
Refine lint/test configuration. (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored Aug 30, 2023
1 parent 2d4830e commit 4054269
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
name: black
types:
- python
- entry: pipenv run python -m isort
- entry: pipenv run python -m isort --filter-files
id: isort
language: system
name: isort
Expand All @@ -54,7 +54,7 @@ repos:
require_serial: true
types:
- python
- entry: pipenv run python -m ruff
- entry: pipenv run python -m ruff --force-exclude
id: ruff
language: system
name: ruff
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ dev:

# Check lint with black.
black:
${PIPRUN} python -m black --check docs test src
${PIPRUN} python -m black --check .

# Check lint with isort.
isort:
${PIPRUN} python -m isort .
${PIPRUN} python -m isort --check .

# Check lint with mypy.
mypy:
${PIPRUN} python -m mypy docs test src
${PIPRUN} python -m mypy .

# Check lint with ruff.
ruff:
${PIPRUN} python -m ruff docs test src
${PIPRUN} python -m ruff .

# Check lint with toml-sort.
toml-sort:
Expand Down
21 changes: 15 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,26 @@ serious-scaffold-cli = "serious_scaffold.cli:app"
homepage = "https://github.com/serious-scaffold/serious-scaffold-python/"
issue = "https://github.com/serious-scaffold/serious-scaffold-python/issues"

[tool.black]
force-exclude = '''
(
template/.*
)
'''

[tool.coverage.report]
fail_under = 100

[tool.coverage.run]
omit = [
"src/{{ module_name }}/**",
]
source = [
"serious_scaffold",
]

[tool.isort]
filter_files = true
color_output = true
extend_skip = [
"template",
]
profile = "black"

[tool.mypy]
Expand All @@ -62,7 +69,7 @@ enable_error_code = [
"ignore-without-code",
]
exclude = [
"src/{{ module_name }}",
"template",
]
no_implicit_optional = true
show_error_codes = true
Expand All @@ -78,6 +85,9 @@ log_format = "%(asctime)s %(levelname)s %(message)s"
minversion = "6.0"

[tool.ruff]
extend-exclude = [
"template",
]
extend-ignore = [
"D203",
"D204",
Expand All @@ -97,7 +107,6 @@ src = ["src"]

[tool.ruff.per-file-ignores]
"docs/conf.py" = ["INP001"]
"src/\\{\\{ module_name \\}\\}/__init__.py" = ["N999"]
"test/*" = ["S101"]

[tool.setuptools.dynamic]
Expand Down
4 changes: 2 additions & 2 deletions template/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
name: black
types:
- python
- entry: pipenv run python -m isort
- entry: pipenv run python -m isort --filter-files
id: isort
language: system
name: isort
Expand All @@ -54,7 +54,7 @@ repos:
require_serial: true
types:
- python
- entry: pipenv run python -m ruff
- entry: pipenv run python -m ruff --force-exclude
id: ruff
language: system
name: ruff
Expand Down
8 changes: 4 additions & 4 deletions template/Makefile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ dev:

# Check lint with black.
black:
${PIPRUN} python -m black --check docs test src
${PIPRUN} python -m black --check .

# Check lint with isort.
isort:
${PIPRUN} python -m isort .
${PIPRUN} python -m isort --check .

# Check lint with mypy.
mypy:
${PIPRUN} python -m mypy docs test src
${PIPRUN} python -m mypy .

# Check lint with ruff.
ruff:
${PIPRUN} python -m ruff docs test src
${PIPRUN} python -m ruff .

# Check lint with toml-sort.
toml-sort:
Expand Down
33 changes: 23 additions & 10 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,31 @@ requires-python = ">={{ min_py }}"
[project.urls]
homepage = "https://{{ repo_url() }}/"
issue = "https://{{ repo_base_url() }}/issues"
[%- if project_name == "Serious Scaffold Python" %]

[tool.black]
force-exclude = '''
(
template/.*
)
'''
[%- endif %]

[tool.coverage.report]
fail_under = {{ coverage_threshold }}

[tool.coverage.run]
omit = [
[%- if project_name == "Serious Scaffold Python" %]
"src/{{ '{{ module_name }}' }}/**",
[%- endif %]
]
source = [
"{{ module_name }}",
]

[tool.isort]
filter_files = true
color_output = true
[%- if project_name == "Serious Scaffold Python" %]
extend_skip = [
"template",
]
[%- endif %]
profile = "black"

[tool.mypy]
Expand All @@ -74,11 +83,11 @@ disallow_untyped_defs = true
enable_error_code = [
"ignore-without-code",
]
exclude = [
[%- if project_name == "Serious Scaffold Python" %]
"src/{{ '{{ module_name }}' }}",
[%- endif %]
exclude = [
"template",
]
[%- endif %]
no_implicit_optional = true
show_error_codes = true
warn_return_any = true
Expand All @@ -93,6 +102,11 @@ log_format = "%(asctime)s %(levelname)s %(message)s"
minversion = "6.0"

[tool.ruff]
[%- if project_name == "Serious Scaffold Python" %]
extend-exclude = [
"template",
]
[%- endif %]
extend-ignore = [
"D203",
"D204",
Expand All @@ -112,7 +126,6 @@ src = ["src"]

[tool.ruff.per-file-ignores]
"docs/conf.py" = ["INP001"]
"src/\\{\\{ module_name \\}\\}/__init__.py" = ["N999"]
"test/*" = ["S101"]

[tool.setuptools.dynamic]
Expand Down

0 comments on commit 4054269

Please sign in to comment.