Skip to content

Commit

Permalink
Merge pull request #186 from lsst-sqre/tickets/DM-45138
Browse files Browse the repository at this point in the history
DM-45138: Use shared Ruff configuration, update dependencies
  • Loading branch information
rra committed Jul 8, 2024
2 parents 0bdce35 + 2022e19 commit 2d24fdc
Show file tree
Hide file tree
Showing 8 changed files with 623 additions and 576 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8
rev: v0.5.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ help:

.PHONY: init
init:
pip install --upgrade uv
pip install --upgrade pip uv
uv pip install -r requirements/main.txt -r requirements/dev.txt \
-r requirements/tox.txt
uv pip install --editable .
Expand All @@ -21,7 +21,7 @@ update: update-deps init

.PHONY: update-deps
update-deps:
pip install --upgrade uv
pip install --upgrade pip uv
uv pip install --upgrade pre-commit
pre-commit autoupdate
uv pip compile --upgrade --generate-hashes \
Expand All @@ -35,8 +35,6 @@ update-deps:
.PHONY: update-deps-no-hashes
update-deps-no-hashes:
pip install --upgrade uv
uv pip install pre-commit
pre-commit autoupdate
uv pip compile --upgrade \
--output-file requirements/main.txt requirements/main.in
uv pip compile --upgrade \
Expand Down
115 changes: 7 additions & 108 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,130 +101,29 @@ filterwarnings = [
# listed in python_files.
python_files = ["tests/*.py", "tests/*/*.py"]

# 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/
# Use the generic Ruff configuration in ruff.toml and extend it with only
# project-specific settings.
[tool.ruff]
exclude = [
"docs/**",
]
line-length = 79
target-version = "py312"

[tool.ruff.lint]
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
"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
"D205", # our documentation style allows a folded first line
"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
"FIX002", # point of a TODO comment is that we're not ready to fix it
"G004", # forbidding logging f-strings is appealing, but not our style
"RET505", # disagree that omitting else always makes code more readable
"PLR0911", # often many returns is clearer and simpler style
"PLR0913", # factory pattern uses constructors with many arguments
"PLR2004", # too aggressive about magic values
"PLW0603", # yes global is discouraged but if needed, it's needed
"S105", # good idea but too many false positives on non-passwords
"S106", # good idea but too many false positives on non-passwords
"S107", # good idea but too many false positives on non-passwords
"S603", # not going to manually mark every subprocess call as reviewed
"S607", # using PATH is not a security vulnerability
"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
"TRY301", # sometimes raising exceptions inside try is the best flow
"UP040", # PEP 695 type aliases not yet supported by mypy

# The following settings should be disabled when using ruff format
# per https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
"E111",
"E114",
"E117",
"D206",
"D300",
"Q000",
"Q001",
"Q002",
"Q003",
"COM812",
"COM819",
"ISC001",
"ISC002",
]
select = ["ALL"]
extend = "ruff-shared.toml"

[tool.ruff.lint.per-file-ignores]
"src/uws/handlers.py" = [
"D103", # FastAPI handlers should not have docstrings
]
[tool.ruff.lint.extend-per-file-ignores]
"src/vocutouts/config.py" = [
"S108", # use of /tmp is safe in this context
]
"src/vocutouts/handlers/**" = [
"D103", # FastAPI handlers should not have docstrings
]
"src/vocutouts/models/request.py" = [
"TRY004", # pydantic requires ValueError, not TypeError
]
"src/vocutouts/uws/handlers.py" = [
"D103", # FastAPI handlers should not have docstrings
]
"src/vocutouts/workers/cutout.py" = [
"S108", # use of /tmp is safe in this context
]
"tests/**" = [
"C901", # tests are allowed to be complex, sometimes that's convenient
"D101", # tests don't need docstrings
"D103", # tests don't need docstrings
"PLR0915", # tests are allowed to be long, sometimes that's convenient
"PT012", # way too aggressive about limiting pytest.raises blocks
"S101", # tests should use assert
"S106", # tests are allowed to hard-code dummy passwords
"S301", # one test verifies that exceptions can be pickled
"SLF001", # tests are allowed to access private members
]

[tool.ruff.lint.isort]
known-first-party = ["vocutouts", "tests"]
split-on-trailing-comma = false

# These are too useful as attributes or methods to allow the conflict with the
# built-in to rule out their use.
[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = [
"all",
"any",
"help",
"id",
"list",
"type",
]

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false

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

[tool.scriv]
categories = [
"Backwards-incompatible changes",
Expand Down
Loading

0 comments on commit 2d24fdc

Please sign in to comment.