From 9621cee3d81981c45556ebe51452aa349f38463d Mon Sep 17 00:00:00 2001 From: Rhys Goodall Date: Tue, 20 Aug 2024 18:51:38 -0400 Subject: [PATCH] fea: use ruff 0.6.1 --- .pre-commit-config.yaml | 45 +++----------------- pyproject.toml | 94 ++++++++++++++++++++++++++++------------- setup.cfg | 4 +- 3 files changed, 70 insertions(+), 73 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ae4223d7..05442bc1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,44 +15,9 @@ repos: - id: trailing-whitespace exclude: *exclude_files - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.1 hooks: - - id: black - name: Black Formating - exclude: *exclude_files - - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - name: Sort imports - exclude: *exclude_files - - - repo: https://github.com/PyCQA/pylint - rev: pylint-2.5.2 - hooks: - - id: pylint - language: system - args: [ - '--disable=line-too-long', - '--disable=no-member', - '--disable=missing-module-docstring', - '--disable=missing-class-docstring', - '--disable=missing-function-docstring', - '--disable=too-many-arguments', - '--disable=too-many-locals', - '--disable=not-callable', - '--disable=logging-fstring-interpolation', - '--disable=logging-not-lazy', - '--disable=invalid-name', - '--disable=too-few-public-methods', - '--disable=too-many-instance-attributes', - '--disable=too-many-statements', - '--disable=too-many-branches', - '--disable=import-outside-toplevel', - '--disable=cell-var-from-loop', - '--disable=duplicate-code', - '--disable=use-dict-literal', - ] - exclude: *exclude_files \ No newline at end of file + - id: ruff + args: [ --fix] + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 05037dc7..677428ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,36 +5,70 @@ requires = [ ] build-backend = "setuptools.build_meta" -# Make isort compatible with black -[tool.isort] -profile = "black" - -# Pylint -[tool.pylint.'MESSAGES CONTROL'] -disable = [ - "line-too-long", - "no-member", - "missing-module-docstring", - "missing-class-docstring", - "missing-function-docstring", - "too-many-arguments", - "too-many-locals", - "not-callable", - "logging-fstring-interpolation", - "logging-not-lazy", - "invalid-name", - "too-few-public-methods", - "too-many-instance-attributes", - "too-many-statements", - "too-many-branches", - "import-outside-toplevel", - "cell-var-from-loop", - "duplicate-code", - "use-dict-literal", -] - -[tool.pylint.MASTER] -ignore-paths = [ +[tool.ruff] +target-version = "py37" +line-length = 120 +exclude = [ "^mace/tools/torch_geometric/.*$", "^mace/tools/scatter.py$", ] + +[tool.ruff.lint] +select = ["ALL"] +ignore = [ + # Rule families + "ANN", # flake8-annotations (not ready, require types for ALL args) + "ARG", # Check for unused function arguments + "BLE", # General catch of Exception + "C90", # Check for functions with a high McCabe complexity + "COM", # flake8-commas (conflict with line wrapper) + "CPY", # Missing copyright notice at top of file (need preview mode) + "D", # pydocstyle + "EM", # Format nice error messages + "ERA", # Check for commented-out code + "FIX", # Check for FIXME, TODO and other developer notes + "FURB", # refurb (need preview mode, too many preview errors) + "G", # validate logging format strings + "INP", # Ban PEP-420 implicit namespace packages + "N", # pep8-naming (many var/arg names are intended) + "NPY", # NumPy-specific rules (TODO: enable this) + "PTH", # Prefer pathlib over os.path + "S", # flake8-bandit (TODO: enable this) + "SLF", # Access "private" class members + "T20", # Check for print/pprint + "TD", # TODO tags related + + # Single rules + "B023", # Function definition does not bind loop variable + "B028", # No explicit stacklevel keyword argument found + "B904", # Within an except clause, raise exceptions with ... + "C408", # unnecessary-collection-call + "D105", # Missing docstring in magic method + "D205", # 1 blank line required between summary line and description + "D212", # Multi-line docstring summary should start at the first line + "DTZ003", # TODO: fix this (issue #3791) + "E501", # Line too long + "FBT001", # Boolean-typed positional argument in function definition + "FBT002", # Boolean default positional argument in function + "ISC001", # Ignore for purpose of auto formatting + "N801", # Invalid Name + "PD901", # pandas-df-variable-name + "PERF203", # try-except-in-loop + "PERF401", # manual-list-comprehension + "PLR0911", # too many return statements + "PLR0912", # too many branches + "PLR0913", # too many arguments + "PLR0915", # too many statements + "PLR2004", # magic values in comparison + "PLW2901", # Outer for loop variable overwritten by inner assignment target + "PT013", # pytest-incorrect-pytest-import + "PYI024", # Use `typing.NamedTuple` instead of `collections.namedtuple` + "RET505", # Unnecessary `else` after `return` statement + "SIM105", # Use contextlib.suppress() instead of try-except-pass + "TRY003", # Avoid specifying long messages outside the exception class + "TRY300", # Checks for return statements in try blocks + "TRY301", # Checks for raise statements within try blocks +] +pydocstyle.convention = "google" +isort.split-on-trailing-comma = false +isort.required-imports = ["from __future__ import annotations"] diff --git a/setup.cfg b/setup.cfg index 81e0b661..11753e22 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,10 +44,8 @@ console_scripts = [options.extras_require] wandb = wandb dev = - black - isort + ruff mypy pre-commit pytest - pylint schedulefree = schedulefree \ No newline at end of file