Skip to content

Set up ruff in this repository #239

@justinchuby

Description

@justinchuby

Here is a reference ruff config. Please set up ruff for this repository and add it to the CI. You can use this action and remove flake8 configs.

- uses: astral-sh/ruff-action@v3
[tool.ruff]
line-length = 95
target-version = "py39"

[tool.ruff.lint]
select = [
    "B", # flake8-bugbear
    "C4", # flake8-comprehensions
    "E", # pycodestyle
    "F", # Pyflakes
    "G", # flake8-logging-format
    "I", # isort
    "ISC", # flake8-implicit-str-concat
    "LOG", # flake8-logging
    "N", # pep8-naming
    "NPY", # modern numpy
    "PERF", # Perflint
    "PIE", # flake8-pie
    "PYI", # flake8-pyi
    "RUF", # Ruff-specific rules
    "SIM", # flake8-simplify
    "SLOT", # flake8-slot
    "T10", # flake8-debugger
    "TID", # Disallow relative imports
    "TRY", # flake8-try-except-raise
    "UP", # pyupgrade
    "W", # pycodestyle
    "YTT", # flake8-2020
]
# Select preview rules
preview = true
ignore = [
    "B9",  # Opinionated bugbear rules
    "C408", # Sometimes it is preferable when we construct kwargs
    "D1", # D1 is for missing docstrings, which is not yet enforced.
    "D401", # First line of docstring should be in imperative mood
    "E1", "E2", "E3", # Pycodestyle formatting rules that conflicts with the formatter
    "E501", # Line length. Not enforced because black will handle formatting
    "SIM103", # "Return the condition directly" obscures logic sometimes
    "N802", # Nxx: ONNX Script function sometimes use upper case for names.
    "N803",
    "N806",
    "N999", # Invalid module name
    "NPY002", # We may not always need a generator
    "PERF203", # try-except in loops sometimes necessary
    "PERF401", # List comprehension is not always readable
    "PYI041", # int | float is more clear
    "RUF022", # We don't need to sort __all__ for elements to be grouped
    "RUF031", # Parentheses for tuple in subscripts is more readable
    "RUF052", # Variables with `_` prefix may not be dummy variables in all cases
    "SIM102", # Collapible if statements are not always more readable
    "SIM108", # We don't always encourage ternary operators
    "SIM114", # Don't always combine if branches for debugability
    "SIM116", # Don't use dict lookup to replace if-else
    "TRY003", # Messages can be constructed in the exception
]

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions