diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7ee3cc4e7..aa076e6be 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,17 +22,8 @@ repos: hooks: - id: black args: ["--config=python/pyproject.toml"] - - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 - hooks: - - id: flake8 - args: ["--config=python/.flake8"] - files: python/.*$ - types: [file] - types_or: [python, cython] - additional_dependencies: ["flake8-force"] - repo: https://github.com/MarcoGorelli/cython-lint - rev: v0.1.10 + rev: v0.15.0 hooks: - id: cython-lint - repo: https://github.com/pre-commit/mirrors-clang-format @@ -78,6 +69,11 @@ repos: # of dependencies, so we'll have to update this manually. additional_dependencies: - cmakelang==0.6.13 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.278 + hooks: + - id: ruff + files: python/.*$ default_language_version: python: python3 diff --git a/pyproject.toml b/pyproject.toml index 8a412773e..285098f99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,16 @@ ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b" ignore-words-list = "inout" builtin = "clear" quiet-level = 3 + +[tool.ruff] +select = ["E", "F", "W"] +ignore = [ + # whitespace before : + "E203", +] +fixable = ["ALL"] +exclude = [ + # TODO: Remove this in a follow-up where we fix __all__. + "__init__.py", +] +line-length = 79 diff --git a/python/.flake8 b/python/.flake8 deleted file mode 100644 index 4d610ba8e..000000000 --- a/python/.flake8 +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. - -[flake8] -filename = *.py, *.pyx, *.pxd, *.pxi -exclude = __init__.py, *.egg, build, docs, .git -force-check = True -ignore = - # line break before binary operator - W503, - # whitespace before : - E203 -per-file-ignores = - # Rules ignored only in Cython: - # E211: whitespace before '(' (used in multi-line imports) - # E225: Missing whitespace around operators (breaks cython casting syntax like ) - # E226: Missing whitespace around arithmetic operators (breaks cython pointer syntax like int*) - # E227: Missing whitespace around bitwise or shift operator (Can also break casting syntax) - # E275: Missing whitespace after keyword (Doesn't work with Cython except?) - # E402: invalid syntax (works for Python, not Cython) - # E999: invalid syntax (works for Python, not Cython) - # W504: line break after binary operator (breaks lines that end with a pointer) - *.pyx: E211, E225, E226, E227, E275, E402, E999, W504 - *.pxd: E211, E225, E226, E227, E275, E402, E999, W504 - *.pxi: E211, E225, E226, E227, E275, E402, E999, W504