fix(playground): resolve the 11 ruff violations in backend_manager - #89
Closed
basil-k-aji-dev wants to merge 1 commit into
Closed
basil-k-aji-dev wants to merge 1 commit into
basil-k-aji-dev wants to merge 1 commit into
Conversation
`uv run ruff check .` has failed on main since the playground merge, so every pull request opens with a red Lint step that has nothing to do with its own contents. Apply the fixes ruff already proposes: `datetime.UTC` for `timezone.utc` (UP017), `X | None` for `Optional[X]` (UP045), and unquoted annotations (UP037). `UTC is timezone.utc`, so the timestamp behaviour is unchanged. The two UP037 sites annotate optional dependencies (`bigquery`, `docker`, both imported inside `try/except ImportError`), which is presumably why the annotations were quoted. Removing the quotes is safe here because both are attribute annotations inside `__init__`: Python does not evaluate annotations on complex targets in a function body, so the name is never looked up when the package is absent. The same annotation at class level would raise NameError. Drop the imports these rewrites orphaned (`timezone` in three modules, `Optional` in two). F401 is disabled for this repo so ruff does not flag them, but they are dead. `bigquery_service` keeps its pre-existing unused `datetime, timezone` import, which predates this change. Closes google#29.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #29.
Problem
uv run ruff check .has failed onmainsince the playground merge (#24), with 11 errors inplayground/backend_manager. The practical cost is the one #18 describes: every new pull request opens with a red Lint Python step that has nothing to do with its own contents.Change
The fixes ruff already proposes:
timezone.utc→UTCOptional[X]→X | NoneUTC is timezone.utcisTrue(the alias has existed since 3.11), so timestamp behaviour is byte-for-byte unchanged:On the two UP037 sites — worth a look, because they are the risky-looking ones
Both annotate an optional dependency, which is presumably why they were quoted in the first place:
Removing the quotes is safe here because both are attribute annotations inside
__init__. Python does not evaluate annotations on complex targets in a function body, sodockeris never looked up when the package is absent. I checked rather than assumed, on the project's 3.12:So the identical annotation moved to class level would break the no-docker install path. It is not moving, and
python -m compileallis clean on both packages.Orphaned imports
The rewrites left
timezoneunused in three modules andOptionalunused in two.F401is in this repo's ruffignorelist so nothing flags them, but they are dead, so I removed them.bigquery_servicekeeps its pre-existing unusedfrom datetime import datetime, timezone— that one predates this change and is outside the issue's scope.Verification
uv run ruff check .uv run ruff format --check .uv run python scripts/quality_ratchet.pyuv run python -m compileallon both packagesuv run pytest -qis unaffected:playground/is not intestpaths, and the full suite shows the same results asmainon this host.make typecheckcould not be run in my environment — thepyrightwheel downloads a Node runtime on first use and my sandbox blocks it. No touched file is inpyright-core.json.