Skip to content

fix: add stricter lint checks and fix the defects they found - #1401

Merged
JuanLeee merged 1 commit into
mainfrom
chore/lint-config
Nov 30, 2026
Merged

JuanLeee merged 1 commit into
mainfrom
chore/lint-config

Conversation

@JuanLeee

@JuanLeee JuanLeee commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds stricter static checks to CI and fixes the defects they found on main.

Checks added

  • mypy: strict_equality, warn_unused_ignores, ignore-without-code and unused-awaitable.
  • ruff, run alongside flake8: B, ASYNC, RUF006, and TID251 to ban psycopg, mysql and aiomysql imports outside the driver dialects.
  • import-linter: only the aio tree and the async SQLAlchemy dialects import aio, and the plugin service and wrapper modules do not import the Django or SQLAlchemy integrations.

CI runs ruff check . and lint-imports after isort. ruff and import-linter are new dev dependencies; import-linter is pinned to 2.15, the last release that supports Python 3.10.

Fixes

  • The sync is_static_host_list_provider() compared the provider instance with a class, so it always returned False and the two branches that called it never ran. The method and both branches are removed, so stale DNS and read/write splitting behave as they do on main.
  • The blue/green status provider bound green_host late in a loop, so every IAM success handler registered the last green host.
  • The aio topology monitor dropped the tasks it scheduled, so they could be garbage-collected before they finished.
  • HostResponseTimeMonitor kept its closed connection after stopping, and its tests compared values without asserting them.

The PR also removes 79 # type: ignore comments that no longer hid anything, and fixes smaller issues the checks flagged, mostly in tests.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@JuanLeee JuanLeee changed the title chore: add ruff, import-linter and stricter mypy checks fix: add stricter lint checks and fix the defects they found Nov 30, 2026
Checks added:

- mypy: strict_equality, warn_unused_ignores, ignore-without-code and
  unused-awaitable.
- ruff, run alongside flake8: B, ASYNC, RUF006, and TID251 to ban
  psycopg, mysql and aiomysql imports outside the driver dialects.
- import-linter: only the aio tree and the async SQLAlchemy dialects
  import aio, and the plugin service and wrapper modules do not import
  the Django or SQLAlchemy integrations.

CI runs ruff check . and lint-imports after isort. ruff and
import-linter are new dev dependencies; import-linter is pinned to 2.15,
the last release that supports Python 3.10.

Fixes:

- The sync is_static_host_list_provider() compared the provider
  instance with a class, so it always returned False and the two
  branches that called it never ran. The method and both branches are
  removed, so stale DNS and read/write splitting behave as they do on
  main.
- The blue/green status provider bound green_host late in a loop, so
  every IAM success handler registered the last green host.
- The aio topology monitor dropped the tasks it scheduled, so they could
  be garbage-collected before they finished.
- HostResponseTimeMonitor kept its closed connection after stopping, and
  its tests compared values without asserting them.

Also removes 79 type: ignore comments that no longer hid anything, and
fixes smaller issues the checks flagged, mostly in tests.
@JuanLeee
JuanLeee merged commit d54172b into main Nov 30, 2026
9 checks passed
@JuanLeee
JuanLeee deleted the chore/lint-config branch November 30, 2026 18:31
JuanLeee added a commit that referenced this pull request Dec 2, 2026
Main's #1401 turned on mypy's warn_unused_ignores and strict_equality
and ruff's B905, which the kms code predates.

- Drop 18 type: ignore comments in unannotated test functions, whose
  bodies mypy does not check.
- Pass strict=False to 13 zip() calls, as #1401 did, so behaviour stays
  the same.
- Cast the driver iterator to object in AwsWrapperCursor.__next__: a
  driver cursor can be its own iterator, which the Cursor type does
  not show.
JuanLeee added a commit that referenced this pull request Dec 2, 2026
#1294 added it after #1401 turned on warn_unused_ignores. mypy skips the
body of the unannotated test, so the ignore is unused on every Python
version and the check fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants