diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dabf94a..2802cac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.2.1 + rev: v0.6.4 hooks: # Run the linter. - id: ruff diff --git a/ruff-base.toml b/ruff-base.toml new file mode 100644 index 0000000..836205f --- /dev/null +++ b/ruff-base.toml @@ -0,0 +1,59 @@ +# Copied originally from pandas. This config requires ruff >= 0.2. +target-version = "py311" + +# fix = true +lint.unfixable = [] + +lint.select = [ + "I", # isort + "F", # pyflakes + "E", "W", # pycodestyle + "YTT", # flake8-2020 + "B", # flake8-bugbear + "Q", # flake8-quotes + "T10", # flake8-debugger + "INT", # flake8-gettext + "PLC", "PLE", "PLR", "PLW", # pylint + "PIE", # misc lints + "PYI", # flake8-pyi + "TID", # tidy imports + "ISC", # implicit string concatenation + "TCH", # type-checking imports + "C4", # comprehensions + "PGH" # pygrep-hooks +] + +# Some additional rules that are useful +lint.extend-select = [ +"UP009", # UTF-8 encoding declaration is unnecessary +"SIM118", # Use `key in dict` instead of `key in dict.keys()` +"D205", # One blank line required between summary line and description +"ARG001", # Unused function argument +"RSE102", # Unnecessary parentheses on raised exception +"PERF401", # Use a list comprehension to create a transformed list +] + +lint.ignore = [ + "ISC001", # Disable this for compatibility with ruff format + "E402", # module level import not at top of file + "E731", # do not assign a lambda expression, use a def + "PLR2004", # Magic number + "B028", # No explicit `stacklevel` keyword argument found + "PLR0913", # Too many arguments to function call + "PLR1730", # Checks for if statements that can be replaced with min() or max() calls +] + +extend-exclude = [ + "docs", +] + +[lint.pycodestyle] +max-line-length = 100 # E501 reports lines that exceed the length of 100. + +[lint.extend-per-file-ignores] +"__init__.py" = ["E402", "F401", "F403"] +# For tests: +# - D205: Don't worry about test docstrings +# - ARG001: Unused function argument false positives for some fixtures +# - E501: Line-too-long +"**/tests/test_*.py" = ["D205", "ARG001", "E501"] diff --git a/ruff.toml b/ruff.toml index be10018..53de55b 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,74 +1,25 @@ -# Copied originally from pandas -target-version = "py310" - -# fix = true -unfixable = [] - -select = [ - "I", # isort - "F", # pyflakes - "E", "W", # pycodestyle - "YTT", # flake8-2020 - "B", # flake8-bugbear - "Q", # flake8-quotes - "T10", # flake8-debugger - "INT", # flake8-gettext - "PLC", "PLE", "PLR", "PLW", # pylint - "PIE", # misc lints - "PYI", # flake8-pyi - "TID", # tidy imports - "ISC", # implicit string concatenation - "TCH", # type-checking imports - "C4", # comprehensions - "PGH" # pygrep-hooks -] - -# Some additional rules that are useful -extend-select = [ -"UP009", # UTF-8 encoding declaration is unnecessary -"SIM118", # Use `key in dict` instead of `key in dict.keys()` -"D205", # One blank line required between summary line and description -"ARG001", # Unused function argument -"RSE102", # Unnecessary parentheses on raised exception -"PERF401", # Use a list comprehension to create a transformed list -] - -ignore = [ - "ISC001", # Disable this for compatibility with ruff format - "B028", # No explicit `stacklevel` keyword argument found - "B905", # `zip()` without an explicit `strict=` parameter - "E402", # module level import not at top of file - "E731", # do not assign a lambda expression, use a def - "PLC1901", # compare-to-empty-string - "PLR0911", # Too many returns - "PLR0912", # Too many branches - "PLR0913", # Too many arguments to function call - "PLR0915", # Too many statements - "PLR2004", # Magic number -] - -# TODO : fix these and stop ignoring. Commented out ones are common and OK to except. -extend-ignore = [ - "PGH004", # Use specific rule codes when using `noqa` -# "C401", # Unnecessary generator (rewrite as a `set` comprehension) -# "C402", # Unnecessary generator (rewrite as a dict comprehension) -# "C405", # Unnecessary `list` literal (rewrite as a `set` literal) -# "C408", # Unnecessary `dict` call (rewrite as a literal) -# "C416", # Unnecessary `dict` comprehension (rewrite using `dict()`) -# "PGH002", # warn is deprecated in favor of warning -# "PYI056", # Calling `.append()` on `__all__` may not be supported by all type checkers -] +extend = "ruff-base.toml" +# These are files to exclude for this project. extend-exclude = [ - "docs", + # "**/*.ipynb", # commonly not ruff-compliant ] -[pycodestyle] -max-line-length = 100 # E501 reports lines that exceed the length of 100. - -[lint.extend-per-file-ignores] -"__init__.py" = ["E402", "F401", "F403"] -# For tests: -# - D205: Don't worry about test docstrings -# - ARG001: Unused function argument false positives for some fixtures -"**/tests/test_*.py" = ["D205", "ARG001"] +# These are rules that commonly cause many ruff warnings. Code will be improved by +# incrementally fixing code to adhere to these rules, but for practical purposes they +# can be ignored by uncommenting each one. You can also add to this list as needed. +lint.extend-ignore = [ + # "B905", # `zip()` without an explicit `strict=` parameter + # "PLC1901", # compare-to-empty-string + # "PLR0911", # Too many returns + # "PLR0912", # Too many branches + # "PLR0915", # Too many statements + # "PGH004", # Use specific rule codes when using `noqa` + # "C401", # Unnecessary generator (rewrite as a `set` comprehension) + # "C402", # Unnecessary generator (rewrite as a dict comprehension) + # "C405", # Unnecessary `list` literal (rewrite as a `set` literal) + # "C408", # Unnecessary `dict` call (rewrite as a literal) + # "C416", # Unnecessary `dict` comprehension (rewrite using `dict()`) + # "G010", # warn is deprecated in favor of warning + # "PYI056", # Calling `.append()` on `__all__` may not be supported by all type checkers +]