chore: better linting - #642
Conversation
jjfrench
left a comment
There was a problem hiding this comment.
Completed a self review and added comments on common patterns addressed by linting
|
|
||
| [tool.ruff.lint] | ||
| select = [ | ||
| "FAST", # fastapi |
There was a problem hiding this comment.
Adds fastapi linting with the exception of FAST003 which doesn't recognize the path parameter being used within the Depends() call
| ] | ||
| ignore = [ | ||
| "BLE001", # Blind Exceptions | ||
| "B008", # Function calls in argument defaults (Fastapi: Depends) |
There was a problem hiding this comment.
Ignoring B008 because Depends() is a fastapi functionality
| "mypy>=2.3.0", | ||
| "pre-commit>=3.8.0", | ||
| "ruff>=0.5.6", |
There was a problem hiding this comment.
Moves mypy to pre-commit, relies on pre-commit-ruff rather than running ruff directly.
Preferred linting:
make lint or uv run pre-commit run --all-files
| uv sync --all-groups --locked | ||
|
|
||
| install: | ||
| uv sync --no-dev --frozen | ||
| uv sync --no-dev --locked | ||
|
|
||
| lint: | ||
| uv run ruff format --diff | ||
| uv run ruff check | ||
| uv run mypy . | ||
|
|
||
| format: | ||
| uv run ruff check --fix | ||
| uv run ruff check --select I --fix | ||
| uv run ruff format |
There was a problem hiding this comment.
Updates dependency installs to use --locked
Updates make lint to run pre-commit hooks
Removes ruff direct usage
| - pydantic>=2.13.4 | ||
| - pydantic-settings>=2.4.1 |
There was a problem hiding this comment.
Equivalent to pydantic.mypy plugin that existed in pyproject.toml
There was a problem hiding this comment.
combines context managers (nested with statements)
| except client.exceptions.NoSuchBucket as e: | ||
| raise ValueError("Bucket doesn't exist.") from e |
There was a problem hiding this comment.
exceptions should be raised "as e from e"
| if TYPE_CHECKING: | ||
| from pypgstac.db import PgstacDB |
There was a problem hiding this comment.
PgstacDB used as a type
| return next( | ||
| (member for member in cls if member.value.lower() == value.lower()), | ||
| cls.unknown, | ||
| ) |
There was a problem hiding this comment.
returning the first member in cls that meets conditions, functionally the same.
both with cls.unknown fallback value
| ) | ||
|
|
||
| all_tenants = sorted(list(set(collection_tenants + item_tenants))) | ||
| all_tenants = sorted(set(collection_tenants + item_tenants)) |
There was a problem hiding this comment.
sorted will output a new list
d5ba7f2 to
fd045e9
Compare
fd045e9 to
391b018
Compare
Issue
What?
Why?
Testing?