Skip to content

Add more Ruff rule sets for better code quality #1280

@regulartim

Description

@regulartim

Currently we are using 12 Ruff rule sets, defined in pyproject.toml:

[tool.ruff.lint]
select = [
    "B",   # flake8-bugbear
    "C4",  # flake8-comprehensions
    "DJ",  # flake8-django
    "E",   # pycodestyle errors
    "F",   # pyflakes
    "I",   # isort
    "ICN", # flake8-import-conventions
    "LOG", # flake8-logging
    "N",   # pep8-naming
    "TC",  # flake8-type-checking
    "UP",  # pyupgrade
    "W",   # pycodestyle warnings
]

I suggest we should add some more to increase code quality and enforce best practices. I made a list but I am not sure if we really want all of them. We should at least test:

  • A: flake8-builtins
  • BLE: flake8-blind-except <- does not allow catching general Exceptions, which is useful sometimes
  • FURB: refurb
  • FA: flake8-future-annotations
  • FLY: flynt
  • G: flake8-logging-format
  • ISC: flake8-implicit-str-concat
  • NPY: NumPy-specific rules
  • PD: pandas-vet
  • PERF : Perflint (performance optimizations)
  • PIE: flake8-pie
  • PTH: flake8-use-pathlib
  • RET: flake8-return
  • RUF: (maybe exclude RUF012)
  • S: flake8-bandit (maybe exclude tests)
  • SIM: flake8-simplify
  • SLOT: flake8-slots
  • TD: flake8-todos
  • TID: flake8-tidy-imports
  • TRY: tryceratops
  • YTT: flake8-2020 <- outdated

I suggest introducing them in separate PRs, so they are focused and easier to review. Will do this over time, whenever I feel like adding one.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestpythonPull requests that update Python code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions