From 79e9f3c1cef4c69206f92c6fee0f97db528e92ee Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Wed, 3 Apr 2024 16:40:40 +0000 Subject: [PATCH] Add linting configs --- pyproject.toml | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 55a4d9e..4b293ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,93 @@ dependencies = ["coverage[toml]>=6.5", "pytest>=6.0"] [[tool.hatch.envs.testall.matrix]] python = ["3.8", "3.9", "3.10", "3.11", "3.12"] +[tool.isort] +profile = "black" +line_length = 80 +include_trailing_comma = true +use_parentheses = true +known_first_party = ["polymatch"] +float_to_top = true + +[tool.black] +line-length = 80 +target-version = ["py38"] +include = '\.pyi?$' + +[tool.ruff] +line-length = 80 +target-version = 'py38' + +[tool.ruff.format] +docstring-code-format = true +line-ending = "lf" +skip-magic-trailing-comma = true + +[tool.ruff.lint] +ignore-init-module-imports = false +extend-safe-fixes = ["EM101", 'EM102', "TCH001", "SIM117", "SIM108", "ANN201"] +ignore = [ + "D", + "TRY003", # TODO(aspen): Switch to custom exceptions + "ANN101", # Due to be deprecated in ruff + "ANN102", # Due to be deprecated in ruff + "COM812", # Conflicts with formatter + "ISC001", # Conflicts with formatter + "EXE002", # pre-commit does it better, works with SMB shares + "FA100", +] +select = ["ALL"] + +[tool.ruff.lint.per-file-ignores] +"tests/*.py" = [ + "PLR2004", # Allow "magic values" in tests -aspen + "S101", # Allow asserts in tests + "SIM201", # We need to test weird comparison operators + "SIM202", # We need to test weird comparison operstors + "SIM300", # We need to test both forward and reverse comparisons + "FBT001", # Boolean paramters are fine for test cases +] + +[tool.ruff.lint.pycodestyle] +max-line-length = 100 + +[tool.ruff.lint.isort] +split-on-trailing-comma = false + +[tool.ruff.lint.pydocstyle] +convention = "pep257" + +[tool.mypy] +namespace_packages = true +python_version = "3.8" +warn_unused_configs = true +strict = true +strict_optional = true +ignore_missing_imports = true +check_untyped_defs = true +show_error_codes = true +warn_unused_ignores = true +no_implicit_reexport = true +warn_redundant_casts = true +strict_equality = true +disallow_any_generics = true +disallow_untyped_calls = true +disallow_untyped_defs = true +disallow_untyped_decorators = true +extra_checks = true +warn_unreachable = true +warn_return_any = true +warn_no_return = true +enable_error_code = [ + "redundant-self", + "redundant-expr", + "possibly-undefined", + "truthy-bool", + "truthy-iterable", + "ignore-without-code", + "unused-awaitable", +] + [tool.pytest.ini_options] minversion = "6.0" addopts = "--doctest-modules"