Skip to content

chore(mypy): enable the strictness options strict leaves off - #678

Merged
mergify[bot] merged 3 commits into
mainfrom
devs/jd/chore/mypy-strictness/enable-strictness-options-strict-leaves-off--9eee43a7
Aug 5, 2026
Merged

chore(mypy): enable the strictness options strict leaves off#678
mergify[bot] merged 3 commits into
mainfrom
devs/jd/chore/mypy-strictness/enable-strictness-options-strict-leaves-off--9eee43a7

Conversation

@jd

@jd jd commented Aug 5, 2026

Copy link
Copy Markdown
Owner

strict = true is a curated subset, not every check mypy has. These five
error codes and three flags are all off under strict and all report zero
errors on the current tree, so turning them on costs nothing today and
catches regressions from here on:

  • warn_unreachable -- dead branches, which are usually a wrong annotation
    rather than dead code (see the wait_base.__radd__ fix below this commit)
  • disallow_any_unimported -- silent Any leaking in from untyped deps
  • extra_checks -- unsafely overlapping operator signatures, among others
  • ignore-without-code -- keeps type: ignore comments specific
  • redundant-expr, truthy-iterable, unused-awaitable, exhaustive-match

Deliberately left off: disallow_any_expr (655 errors -- unusable for a
decorator library) and disallow_any_decorated (63 errors, all inherent to
@retry wrapping untyped test helpers).

Depends-On: #677

@jd

jd commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 ci: run on pull requests targeting any base branch #683
2 fix: annotate wait_base.radd as taking the int seed from sum() #677
3 chore(mypy): enable the strictness options strict leaves off #678 👈
4 refactor: drop always-true truthiness checks and enable truthy-bool #679
5 refactor: declare BaseAction's REPR_FIELDS and NAME as ClassVar #680
6 test: fix possibly-undefined and deprecated call sites #681
7 refactor: mark overridden methods with @OverRide #682

jd added 3 commits August 5, 2026 17:38
`on.pull_request.branches` filters on the *base* branch, not the head. With
it pinned to `main`, only a pull request merging directly into `main` ran
CI -- every stacked pull request, whose base is the branch below it in the
stack, got no test, lint or mypy run at all and showed nothing but the
Mergify checks.

Drop the filter so CI runs for every pull request regardless of base.

Change-Id: I1c211a106a57b9f4986bec4b76c0680c1a0f1b61
`__radd__` was annotated `other: wait_base`, which is the one type it can
never receive: `wait_base.__add__` always succeeds, so Python never falls
back to the reflected operator for two wait strategies. The only caller is
`sum()`, which seeds its accumulator with the int 0 — hence the
`type: ignore[comparison-overlap]` on `other == 0`, and the dead
`return self` branch behind it that `--warn-unreachable` flags.

Annotate the parameter as `int` and return `NotImplemented` for a non-zero
left operand, so `5 + wait_fixed(1)` raises `TypeError` at the addition
rather than building a `wait_combine` that explodes later when called.

With the signature corrected, mypy infers `sum([...])` over wait strategies
on its own, so four `type: ignore[list-item]` comments in
`test_wait_arbitrary_sum` are no longer needed.

Change-Id: Iad1bcef4412d6afc1a6f1335970cfbfcc4a34fcb
`strict = true` is a curated subset, not every check mypy has. These five
error codes and three flags are all off under `strict` and all report zero
errors on the current tree, so turning them on costs nothing today and
catches regressions from here on:

- `warn_unreachable` -- dead branches, which are usually a wrong annotation
  rather than dead code (see the `wait_base.__radd__` fix below this commit)
- `disallow_any_unimported` -- silent `Any` leaking in from untyped deps
- `extra_checks` -- unsafely overlapping operator signatures, among others
- `ignore-without-code` -- keeps `type: ignore` comments specific
- `redundant-expr`, `truthy-iterable`, `unused-awaitable`, `exhaustive-match`

Deliberately left off: `disallow_any_expr` (655 errors -- unusable for a
decorator library) and `disallow_any_decorated` (63 errors, all inherent to
`@retry` wrapping untyped test helpers).

Change-Id: I9eee43a749050d2bcf0aa0abbedf8725301eba18
@jd
jd force-pushed the devs/jd/chore/mypy-strictness/annotate-wait-base-radd-taking-int-seed-sum--ad1bcef4 branch from b02c344 to ae08acf Compare August 5, 2026 15:39
@jd
jd force-pushed the devs/jd/chore/mypy-strictness/enable-strictness-options-strict-leaves-off--9eee43a7 branch from 5a33f88 to 1897498 Compare August 5, 2026 15:39
@jd

jd commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

Revision history

# Type Changes Reason Date
1 initial 5a33f88 2026-08-05 15:39 UTC
2 rebase 5a33f88 → 1897498 (rebase only) 2026-08-05 15:39 UTC

@mergify

mergify Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 minute 38 seconds in the queue, including 20 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Aug 5, 2026
Base automatically changed from devs/jd/chore/mypy-strictness/annotate-wait-base-radd-taking-int-seed-sum--ad1bcef4 to main August 5, 2026 15:42
@mergify
mergify Bot merged commit 69b3fee into main Aug 5, 2026
9 of 16 checks passed
@mergify
mergify Bot deleted the devs/jd/chore/mypy-strictness/enable-strictness-options-strict-leaves-off--9eee43a7 branch August 5, 2026 15:43
@mergify mergify Bot removed the queued label Aug 5, 2026
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.

1 participant