open-contracting / software-development-handbook

A guide for developers of OCP's tools
https://ocp-software-handbook.readthedocs.io/en/latest/
Other
4 stars 1 forks source link

Use ruff for new projects, to replace flake8, isort, pydocstyle, pyupgrade #92

Open jpmckinney opened 1 year ago

jpmckinney commented 1 year ago

https://github.com/astral-sh/ruff

To match standard-maintenance-scripts:

Can try this config:

[project]
name = ""
version = "0.0.0"

[tool.ruff]
line-length = 119
target-version = "py311"

[tool.ruff.lint]
select = ["ALL"]
ignore = [
  "ANN", "COM", "EM",
  # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
  "W191", "D206", "Q000", "Q001", "Q002", "Q003", "ISC001",
  "D203", "D212",  # ignore incompatible rules
  "D200", "D205",  # documentation preferences
  "C901", "PLR091",  # complexity preferences
]

[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["copyright"]

[tool.ruff.lint.per-file-ignores]
"docs/conf.py" = ["INP001"]  # no __init__.py file
"tests/*" = [
  "D",  # docstring
  "ARG001",  # pytest fixtures
  "PLR0913",  # Too many arguments
  "PLR2004",  # Magic value used
  "S101",  # assert
]

Remember to edit the target-version as needed.

Ignores are because:

jpmckinney commented 1 year ago

Now used on yapw as a first test case. It works well.

Edit: Also used on green-cure and notebooks-ocds.