-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move mypy configuration to pyproject.toml from setup.cfg (#1344)
* Move mypy configuration to pyproject.toml from setup.cfg * Fix mypy GitHub Action to directly call mypy
- Loading branch information
1 parent
ad1f0d6
commit e9e232f
Showing
8 changed files
with
262 additions
and
45 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 |
---|---|---|
@@ -0,0 +1,194 @@ | ||
[build-system] | ||
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] | ||
|
||
[tool.mypy] | ||
disallow_incomplete_defs = true | ||
disallow_untyped_calls = true | ||
disallow_untyped_defs = true | ||
exclude = [ | ||
"^examples/", # examples directory | ||
"^noxfile\\.py$", # nox config file | ||
"setup\\.py$", # any files named setup.py | ||
"^tasks\\.py$", # tasks.py invoke config file | ||
"^tests/", # tests directory | ||
] | ||
show_column_numbers = true | ||
show_error_codes = true | ||
show_error_context = true | ||
strict = true | ||
warn_redundant_casts = true | ||
warn_return_any = true | ||
warn_unreachable = true | ||
warn_unused_ignores = false | ||
|
||
[tool.ruff] | ||
# Exclude a variety of commonly ignored directories. | ||
exclude = [ | ||
".bzr", | ||
".direnv", | ||
".eggs", | ||
".git", | ||
".git-rewrite", | ||
".hg", | ||
".ipynb_checkpoints", | ||
".mypy_cache", | ||
".nox", | ||
".pants.d", | ||
".pyenv", | ||
".pytest_cache", | ||
".pytype", | ||
".ruff_cache", | ||
".svn", | ||
".tox", | ||
".venv", | ||
".vscode", | ||
"__pypackages__", | ||
"_build", | ||
"buck-out", | ||
"build", | ||
"dist", | ||
"node_modules", | ||
"site-packages", | ||
"venv", | ||
] | ||
|
||
# Same as Black. | ||
line-length = 127 | ||
indent-width = 4 | ||
|
||
# Assume Python 3.13 | ||
target-version = "py313" | ||
output-format = "full" | ||
|
||
[tool.ruff.lint] | ||
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. | ||
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or | ||
# McCabe complexity (`C901`) by default. | ||
select = [ | ||
# https://beta.ruff.rs/docs/rules | ||
# "A", # flake8-builtins | ||
# "ANN", # flake8-annotations | ||
# "ARG", # flake8-unused-arguments | ||
"ASYNC", # flake8-async | ||
# "B", # flake8-bugbear | ||
# "BLE", # flake8-blind-except | ||
# "C4", # flake8-comprehensions | ||
"C90", # McCabe cyclomatic complexity | ||
# "COM", # flake8-commas | ||
# "D", # pydocstyle | ||
"DJ", # flake8-django | ||
# "DTZ", # flake8-datetimez | ||
"E", # pycodestyle | ||
# "EM", # flake8-errmsg | ||
# "ERA", # eradicate | ||
# "EXE", # flake8-executable | ||
"F", # Pyflakes | ||
"FA", # flake8-future-annotations | ||
# "FBT", # flake8-boolean-trap | ||
"G", # flake8-logging-format | ||
# "I", # isort | ||
"ICN", # flake8-import-conventions | ||
# "INP", # flake8-no-pep420 | ||
"INT", # flake8-gettext | ||
# "ISC", # flake8-implicit-str-concat | ||
# "N", # pep8-naming | ||
"NPY", # NumPy-specific rules | ||
"PD", # pandas-vet | ||
# "PGH", # pygrep-hooks | ||
# "PIE", # flake8-pie | ||
# "PL", # Pylint | ||
# "PT", # flake8-pytest-style | ||
# "PTH", # flake8-use-pathlib | ||
# "PYI", # flake8-pyi | ||
# "RET", # flake8-return | ||
"RSE", # flake8-raise | ||
# "Q", # flake8-quotes | ||
# "RUF", # Ruff-specific rules | ||
# "S", # flake8-bandit | ||
# "SIM", # flake8-simplify | ||
# "SLF", # flake8-self | ||
# "T10", # flake8-debugger | ||
# "T20", # flake8-print | ||
# "TCH", # flake8-type-checking | ||
# "TD", # flake8-todos | ||
# "TID", # flake8-tidy-imports | ||
# "TRY", # tryceratops | ||
# "UP", # pyupgrade | ||
# "W", # pycodestyle | ||
# "YTT", # flake8-2020 | ||
] | ||
ignore = [ | ||
# `ruff rule S101` for a description of that rule | ||
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` -- FIX ME | ||
"B905", # `zip()` without an explicit `strict=` parameter -- FIX ME | ||
"E501", # Line too long | ||
"EM101", # Exception must not use a string literal, assign to variable first | ||
"EXE001", # Shebang is present but file is not executable -- DO NOT FIX | ||
"G004", # Logging statement uses f-string | ||
"PLC1901", # `{}` can be simplified to `{}` as an empty string is falsey | ||
"PLW060", # Using global for `{name}` but no assignment is done -- DO NOT FIX | ||
"PLW2901", # PLW2901: Redefined loop variable -- FIX ME | ||
"PT011", # `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception | ||
"PT018", # Assertion should be broken down into multiple parts | ||
"S101", # Use of `assert` detected -- DO NOT FIX | ||
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME | ||
"SLF001", # Private member accessed: `_Iterator` -- FIX ME | ||
"UP038", # Use `X | Y` in `{}` call instead of `(X, Y)` -- DO NOT FIX | ||
] | ||
|
||
# Allow fix for all enabled rules (when `--fix`) is provided. | ||
fixable = ["ALL"] | ||
unfixable = [] | ||
|
||
# Allow unused variables when underscore-prefixed. | ||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" | ||
|
||
mccabe.max-complexity = 49 | ||
|
||
per-file-ignores."cmd2/__init__.py" = [ | ||
"E402", # Module level import not at top of file | ||
"F401", # Unused import | ||
] | ||
|
||
per-file-ignores."docs/conf.py" = [ | ||
"F401", # Unused import | ||
] | ||
|
||
per-file-ignores."examples/override_parser.py" = [ | ||
"E402", # Module level import not at top of file | ||
] | ||
|
||
per-file-ignores."examples/scripts/*.py" = [ | ||
"F821", # Undefined name `app` | ||
] | ||
|
||
per-file-ignores."tests/pyscript/*.py" = [ | ||
"F821", # Undefined name `app` | ||
] | ||
|
||
[tool.ruff.format] | ||
# Like Black, use double quotes for strings. | ||
quote-style = "preserve" | ||
|
||
# Like Black, indent with spaces, rather than tabs. | ||
indent-style = "space" | ||
|
||
# Like Black, respect magic trailing commas. | ||
skip-magic-trailing-comma = false | ||
|
||
# Like Black, automatically detect the appropriate line ending. | ||
line-ending = "auto" | ||
|
||
# Enable auto-formatting of code examples in docstrings. Markdown, | ||
# reStructuredText code/literal blocks and doctests are all supported. | ||
# | ||
# This is currently disabled by default, but it is planned for this | ||
# to be opt-out in the future. | ||
docstring-code-format = false | ||
|
||
# Set the line length limit used when formatting code snippets in | ||
# docstrings. | ||
# | ||
# This only has an effect when the `docstring-code-format` setting is | ||
# enabled. | ||
docstring-code-line-length = "dynamic" |
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
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