-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ilbumi/add_linting
Add static code analysis into the the project
- Loading branch information
Showing
8 changed files
with
187 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ pdm.toml | |
.pdm-python | ||
__pypackages__/ | ||
.venv/ | ||
.cache/ | ||
.cache/ | ||
.nox/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[tool.black] | ||
line-length = 120 | ||
exclude = "tests/fixtures" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[mypy] | ||
ignore_missing_imports = true | ||
exclude = tests/fixtures/ | ||
warn_unused_ignores = true | ||
show_error_codes = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
target-version = "py38" | ||
line-length = 132 | ||
exclude = [ | ||
"fixtures", | ||
"site", | ||
] | ||
select = [ | ||
"A", | ||
"ANN", | ||
"ARG", | ||
"B", | ||
"BLE", | ||
"C", | ||
"C4", | ||
"COM", | ||
"D", | ||
"DTZ", | ||
"E", | ||
"ERA", | ||
"EXE", | ||
"F", | ||
"FBT", | ||
"G", | ||
"I", | ||
"ICN", | ||
"INP", | ||
"ISC", | ||
"N", | ||
"PGH", | ||
"PIE", | ||
"PL", | ||
"PLC", | ||
"PLE", | ||
"PLR", | ||
"PLW", | ||
"PT", | ||
"PYI", | ||
"Q", | ||
"RUF", | ||
"RSE", | ||
"RET", | ||
"S", | ||
"SIM", | ||
"SLF", | ||
"T", | ||
"T10", | ||
"T20", | ||
"TCH", | ||
"TID", | ||
"TRY", | ||
"UP", | ||
"W", | ||
"YTT", | ||
] | ||
ignore = [ | ||
"A001", # Variable is shadowing a Python builtin | ||
"ANN101", # Missing type annotation for self | ||
"ANN102", # Missing type annotation for cls | ||
"ANN204", # Missing return type annotation for special method __str__ | ||
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed | ||
"ARG005", # Unused lambda argument | ||
"D105", # Missing docstring in magic method | ||
"D417", # Missing argument description in the docstring | ||
"E501", # Line too long | ||
"ERA001", # Commented out code | ||
"G004", # Logging statement uses f-string | ||
"PLR0911", # Too many return statements | ||
"PLR0915", # Too many statements | ||
"SLF001", # Private member accessed | ||
"TRY003", # Avoid specifying long messages outside the exception class | ||
] | ||
|
||
[per-file-ignores] | ||
"src/*/cli.py" = [ | ||
"T201", # Print statement | ||
] | ||
"scripts/*.py" = [ | ||
"INP001", # File is part of an implicit namespace package | ||
"T201", # Print statement | ||
] | ||
"tests/*.py" = [ | ||
"ARG005", # Unused lambda argument | ||
"FBT001", # Boolean positional arg in function definition | ||
"PLR2004", # Magic value used in comparison | ||
"S101", # Use of assert detected | ||
] | ||
|
||
[flake8-quotes] | ||
docstring-quotes = "double" | ||
|
||
[flake8-tidy-imports] | ||
ban-relative-imports = "all" | ||
|
||
[isort] | ||
known-first-party = ["{{ python_package_import_name }}"] | ||
|
||
[pydocstyle] | ||
convention = "google" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,58 @@ | ||
"""File with common jobs definitions. Run them with 'pdm run nox -e [job_name]'.""" | ||
import os | ||
|
||
import nox | ||
from nox.sessions import Session | ||
|
||
os.environ.update(PDM_IGNORE_SAVED_PYTHON="1", PDM_USE_VENV="1") | ||
|
||
PYSRC = [ | ||
"src/", | ||
"noxfile.py", | ||
"tests/" | ||
] | ||
|
||
@nox.session | ||
def test(session): | ||
def test(session: Session) -> None: | ||
"""Run tests. | ||
|
||
Args: | ||
session (Session): nox session object | ||
""" | ||
session.run_always("pdm", "install", "-G", "ci-tests", external=True) | ||
session.run("pytest", "tests/") | ||
|
||
|
||
@nox.session | ||
def format(session: Session) -> None: | ||
"""Run autoformatters. | ||
|
||
Args: | ||
session (Session): nox session object | ||
""" | ||
session.run_always("pdm", "install", "-G", "ci-quality", external=True) | ||
session.run("ruff", "check", "--config", "config/ruff.toml", "--fix", *PYSRC) | ||
session.run("black", "--config", "config/black.toml", *PYSRC) | ||
|
||
|
||
@nox.session | ||
def lint(session: Session) -> None: | ||
"""Run ruff checks. | ||
|
||
Args: | ||
session (Session): nox session object | ||
""" | ||
session.run_always("pdm", "install", "-G", "ci-quality", external=True) | ||
session.run("ruff", "check", "--config", "config/ruff.toml", *PYSRC) | ||
|
||
|
||
@nox.session | ||
def check_types(session: Session) -> None: | ||
"""Run type checking. | ||
|
||
Args: | ||
session (Session): nox session object | ||
""" | ||
session.run_always("pdm", "install", "-G", "ci-quality", external=True) | ||
session.run("mypy", "--config-file", "config/mypy.ini", *PYSRC) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters