|
| 1 | +[build-system] |
| 2 | +requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] |
| 3 | + |
| 4 | +[tool.mypy] |
| 5 | +disallow_incomplete_defs = true |
| 6 | +disallow_untyped_calls = true |
| 7 | +disallow_untyped_defs = true |
| 8 | +exclude = [ |
| 9 | + "^examples/", # examples directory |
| 10 | + "^noxfile\\.py$", # nox config file |
| 11 | + "setup\\.py$", # any files named setup.py |
| 12 | + "^tasks\\.py$", # tasks.py invoke config file |
| 13 | + "^tests/", # tests directory |
| 14 | +] |
| 15 | +show_column_numbers = true |
| 16 | +show_error_codes = true |
| 17 | +show_error_context = true |
| 18 | +strict = true |
| 19 | +warn_redundant_casts = true |
| 20 | +warn_return_any = true |
| 21 | +warn_unreachable = true |
| 22 | +warn_unused_ignores = false |
| 23 | + |
| 24 | +[tool.ruff] |
| 25 | +# Exclude a variety of commonly ignored directories. |
| 26 | +exclude = [ |
| 27 | + ".bzr", |
| 28 | + ".direnv", |
| 29 | + ".eggs", |
| 30 | + ".git", |
| 31 | + ".git-rewrite", |
| 32 | + ".hg", |
| 33 | + ".ipynb_checkpoints", |
| 34 | + ".mypy_cache", |
| 35 | + ".nox", |
| 36 | + ".pants.d", |
| 37 | + ".pyenv", |
| 38 | + ".pytest_cache", |
| 39 | + ".pytype", |
| 40 | + ".ruff_cache", |
| 41 | + ".svn", |
| 42 | + ".tox", |
| 43 | + ".venv", |
| 44 | + ".vscode", |
| 45 | + "__pypackages__", |
| 46 | + "_build", |
| 47 | + "buck-out", |
| 48 | + "build", |
| 49 | + "dist", |
| 50 | + "node_modules", |
| 51 | + "site-packages", |
| 52 | + "venv", |
| 53 | +] |
| 54 | + |
| 55 | +# Same as Black. |
| 56 | +line-length = 127 |
| 57 | +indent-width = 4 |
| 58 | + |
| 59 | +# Assume Python 3.13 |
| 60 | +target-version = "py313" |
| 61 | +output-format = "full" |
| 62 | + |
| 63 | +[tool.ruff.lint] |
| 64 | +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. |
| 65 | +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or |
| 66 | +# McCabe complexity (`C901`) by default. |
| 67 | +select = [ |
| 68 | + # https://beta.ruff.rs/docs/rules |
| 69 | + # "A", # flake8-builtins |
| 70 | + # "ANN", # flake8-annotations |
| 71 | + # "ARG", # flake8-unused-arguments |
| 72 | + "ASYNC", # flake8-async |
| 73 | + # "B", # flake8-bugbear |
| 74 | + # "BLE", # flake8-blind-except |
| 75 | + # "C4", # flake8-comprehensions |
| 76 | + "C90", # McCabe cyclomatic complexity |
| 77 | + # "COM", # flake8-commas |
| 78 | + # "D", # pydocstyle |
| 79 | + "DJ", # flake8-django |
| 80 | + # "DTZ", # flake8-datetimez |
| 81 | + "E", # pycodestyle |
| 82 | + # "EM", # flake8-errmsg |
| 83 | + # "ERA", # eradicate |
| 84 | + # "EXE", # flake8-executable |
| 85 | + "F", # Pyflakes |
| 86 | + "FA", # flake8-future-annotations |
| 87 | + # "FBT", # flake8-boolean-trap |
| 88 | + "G", # flake8-logging-format |
| 89 | + # "I", # isort |
| 90 | + "ICN", # flake8-import-conventions |
| 91 | + # "INP", # flake8-no-pep420 |
| 92 | + "INT", # flake8-gettext |
| 93 | + # "ISC", # flake8-implicit-str-concat |
| 94 | + # "N", # pep8-naming |
| 95 | + "NPY", # NumPy-specific rules |
| 96 | + "PD", # pandas-vet |
| 97 | + # "PGH", # pygrep-hooks |
| 98 | + # "PIE", # flake8-pie |
| 99 | + # "PL", # Pylint |
| 100 | + # "PT", # flake8-pytest-style |
| 101 | + # "PTH", # flake8-use-pathlib |
| 102 | + # "PYI", # flake8-pyi |
| 103 | + # "RET", # flake8-return |
| 104 | + "RSE", # flake8-raise |
| 105 | + # "Q", # flake8-quotes |
| 106 | + # "RUF", # Ruff-specific rules |
| 107 | + # "S", # flake8-bandit |
| 108 | + # "SIM", # flake8-simplify |
| 109 | + # "SLF", # flake8-self |
| 110 | + # "T10", # flake8-debugger |
| 111 | + # "T20", # flake8-print |
| 112 | + # "TCH", # flake8-type-checking |
| 113 | + # "TD", # flake8-todos |
| 114 | + # "TID", # flake8-tidy-imports |
| 115 | + # "TRY", # tryceratops |
| 116 | + # "UP", # pyupgrade |
| 117 | + # "W", # pycodestyle |
| 118 | + # "YTT", # flake8-2020 |
| 119 | +] |
| 120 | +ignore = [ |
| 121 | + # `ruff rule S101` for a description of that rule |
| 122 | + "B904", # Within an `except` clause, raise exceptions with `raise ... from err` -- FIX ME |
| 123 | + "B905", # `zip()` without an explicit `strict=` parameter -- FIX ME |
| 124 | + "E501", # Line too long |
| 125 | + "EM101", # Exception must not use a string literal, assign to variable first |
| 126 | + "EXE001", # Shebang is present but file is not executable -- DO NOT FIX |
| 127 | + "G004", # Logging statement uses f-string |
| 128 | + "PLC1901", # `{}` can be simplified to `{}` as an empty string is falsey |
| 129 | + "PLW060", # Using global for `{name}` but no assignment is done -- DO NOT FIX |
| 130 | + "PLW2901", # PLW2901: Redefined loop variable -- FIX ME |
| 131 | + "PT011", # `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception |
| 132 | + "PT018", # Assertion should be broken down into multiple parts |
| 133 | + "S101", # Use of `assert` detected -- DO NOT FIX |
| 134 | + "S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME |
| 135 | + "SLF001", # Private member accessed: `_Iterator` -- FIX ME |
| 136 | + "UP038", # Use `X | Y` in `{}` call instead of `(X, Y)` -- DO NOT FIX |
| 137 | +] |
| 138 | + |
| 139 | +# Allow fix for all enabled rules (when `--fix`) is provided. |
| 140 | +fixable = ["ALL"] |
| 141 | +unfixable = [] |
| 142 | + |
| 143 | +# Allow unused variables when underscore-prefixed. |
| 144 | +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" |
| 145 | + |
| 146 | +mccabe.max-complexity = 49 |
| 147 | + |
| 148 | +per-file-ignores."cmd2/__init__.py" = [ |
| 149 | + "E402", # Module level import not at top of file |
| 150 | + "F401", # Unused import |
| 151 | +] |
| 152 | + |
| 153 | +per-file-ignores."docs/conf.py" = [ |
| 154 | + "F401", # Unused import |
| 155 | +] |
| 156 | + |
| 157 | +per-file-ignores."examples/override_parser.py" = [ |
| 158 | + "E402", # Module level import not at top of file |
| 159 | +] |
| 160 | + |
| 161 | +per-file-ignores."examples/scripts/*.py" = [ |
| 162 | + "F821", # Undefined name `app` |
| 163 | +] |
| 164 | + |
| 165 | +per-file-ignores."tests/pyscript/*.py" = [ |
| 166 | + "F821", # Undefined name `app` |
| 167 | +] |
| 168 | + |
| 169 | +[tool.ruff.format] |
| 170 | +# Like Black, use double quotes for strings. |
| 171 | +quote-style = "preserve" |
| 172 | + |
| 173 | +# Like Black, indent with spaces, rather than tabs. |
| 174 | +indent-style = "space" |
| 175 | + |
| 176 | +# Like Black, respect magic trailing commas. |
| 177 | +skip-magic-trailing-comma = false |
| 178 | + |
| 179 | +# Like Black, automatically detect the appropriate line ending. |
| 180 | +line-ending = "auto" |
| 181 | + |
| 182 | +# Enable auto-formatting of code examples in docstrings. Markdown, |
| 183 | +# reStructuredText code/literal blocks and doctests are all supported. |
| 184 | +# |
| 185 | +# This is currently disabled by default, but it is planned for this |
| 186 | +# to be opt-out in the future. |
| 187 | +docstring-code-format = false |
| 188 | + |
| 189 | +# Set the line length limit used when formatting code snippets in |
| 190 | +# docstrings. |
| 191 | +# |
| 192 | +# This only has an effect when the `docstring-code-format` setting is |
| 193 | +# enabled. |
| 194 | +docstring-code-line-length = "dynamic" |
0 commit comments