Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-39857: Remove --flake8 option and add ruff config #250

Merged
merged 13 commits into from
Jul 5, 2023
3 changes: 1 addition & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
shell: bash -l {0}
run: |
conda install -y -q \
"flake8<5" \
pytest pytest-flake8 pytest-xdist pytest-openfiles pytest-cov
pytest pytest-xdist pytest-openfiles pytest-cov

- name: List installed packages
shell: bash -l {0}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ on:
jobs:
call-workflow:
uses: lsst/rubin_workflows/.github/workflows/lint.yaml@main
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ repos:
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.275
hooks:
- id: flake8
- id: ruff
3 changes: 3 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
html_short_title = project
doxylink = {}
exclude_patterns = ["changes/*"]

# Try to pull in links for butler and pipe_base.
intersphinx_mapping["lsst"] = ("https://pipelines.lsst.io/v/daily/", None) # noqa
68 changes: 21 additions & 47 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ dynamic = ["version"]
[project.optional-dependencies]
test = [
"pytest >= 3.2",
"flake8 >= 3.7.5",
"pytest-flake8 >= 1.0.4",
"pytest-openfiles >= 0.5.0"
]

Expand Down Expand Up @@ -110,10 +108,6 @@ line_length = 110
write_to = "python/lsst/ctrl/mpexec/version.py"

[tool.pytest.ini_options]
addopts = "--flake8"
flake8-ignore = ["W503", "E203", "N802", "N803", "N806", "N812", "N815", "N816"]
# The matplotlib test may not release font files.
# Some unit tests open registry database in setUpClass.
open_files_ignore = ["*.ttf", "gen3.sqlite3"]

[tool.pydocstyle]
Expand All @@ -137,62 +131,42 @@ exclude_lines = [
"if TYPE_CHECKING:",
]

# The rule used with Ruff configuration is to disable every lint that has
# legitimate exceptions that are not dodgy code, rather than cluttering code
# with noqa markers. This is therefore a reiatively relaxed configuration that
# errs on the side of disabling legitimate lints.
#
# Reference for settings: https://beta.ruff.rs/docs/settings/
# Reference for rules: https://beta.ruff.rs/docs/rules/
[tool.ruff]
exclude = [
"docs/**",
"__init__.py",
]
line-length = 110
ignore = [
"ANN101", # self should not have a type annotation
"ANN102", # cls should not have a type annotation
"ANN401", # sometimes Any is the right type
"ARG001", # unused function arguments are often legitimate
"ARG002", # unused method arguments are often legitimate
"ARG005", # unused lambda arguments are often legitimate
"BLE001", # we want to catch and report Exception in background tasks
"C414", # nested sorted is how you sort by multiple keys with reverse
"COM812", # omitting trailing commas allows black autoreformatting
"D102", # sometimes we use docstring inheritence
"D104", # don't see the point of documenting every package
"D105", # our style doesn't require docstrings for magic methods
"D106", # Pydantic uses a nested Config class that doesn't warrant docs
"EM101", # justification (duplicate string in traceback) is silly
"EM102", # justification (duplicate string in traceback) is silly
"FBT003", # positional booleans are normal for Pydantic field defaults
"G004", # forbidding logging f-strings is appealing, but not our style
"RET505", # disagree that omitting else always makes code more readable
"PLR0913", # factory pattern uses constructors with many arguments
"PLR2004", # too aggressive about magic values
"S105", # good idea but too many false positives on non-passwords
"S106", # good idea but too many false positives on non-passwords
"SIM102", # sometimes the formatting of nested if statements is clearer
"SIM117", # sometimes nested with contexts are clearer
"TCH001", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH002", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH003", # we decided to not maintain separate TYPE_CHECKING blocks
"TID252", # if we're going to use relative imports, use them always
"TRY003", # good general advice but lint is way too aggressive
"N802",
"N803",
"N806",
"N812",
"N815",
"N816",
"N999",
"D107",
"D105",
"D102",
"D104",
"D100",
"D200",
"D205",
"D400",
"D104",
]
select = ["ALL"]
target-version = "py311"
line-length = 110
select = [
"E", # pycodestyle
"F", # pyflakes
"N", # pep8-naming
"W", # pycodestyle
"D", # pydocstyle
]
target-version = "py310"
extend-select = [
"RUF100", # Warn about unused noqa
]

[tool.ruff.pycodestyle]
max-doc-length = 79

[tool.ruff.pydocstyle]
convention = "numpy"