Tighten mypy and ruff configuration#457
Open
sandhose wants to merge 7 commits intoquenting/modern-tooling/toolingfrom
Open
Tighten mypy and ruff configuration#457sandhose wants to merge 7 commits intoquenting/modern-tooling/toolingfrom
sandhose wants to merge 7 commits intoquenting/modern-tooling/toolingfrom
Conversation
285d656 to
d8149ff
Compare
0fbb49c to
5e8b2d1
Compare
3268987 to
ab14e48
Compare
5e8b2d1 to
a56e1c5
Compare
ab14e48 to
cf4025a
Compare
764bfcb to
7595c86
Compare
93772ed to
92d116c
Compare
7595c86 to
0fac7bb
Compare
92d116c to
43fdd6d
Compare
0fac7bb to
9816f5f
Compare
43fdd6d to
cf97bee
Compare
c8f4a4d to
32a254c
Compare
6af2185 to
85f3e42
Compare
32a254c to
6850192
Compare
85f3e42 to
5cbdc57
Compare
6850192 to
2e6715e
Compare
5cbdc57 to
6882db4
Compare
2e6715e to
a1bf2b9
Compare
6882db4 to
5b98dc0
Compare
a1bf2b9 to
3ce7d40
Compare
5b98dc0 to
22a1320
Compare
3ce7d40 to
ab52477
Compare
22a1320 to
1b61f12
Compare
ab52477 to
31bc4e6
Compare
35792ef to
4d381f3
Compare
2b50fc9 to
56b7c1c
Compare
4d381f3 to
0ccfa57
Compare
56b7c1c to
143fb98
Compare
5214b04 to
cd9fbb6
Compare
143fb98 to
24feab2
Compare
f975771 to
7fc88c8
Compare
6f8546b to
17a648c
Compare
7fc88c8 to
b7305b6
Compare
1f24aa4 to
c6bdaa6
Compare
b513718 to
462b67b
Compare
c6bdaa6 to
6bf3f1f
Compare
462b67b to
bc34152
Compare
6bf3f1f to
6c3b661
Compare
logging.warn() was deprecated in Python 3.3. All call sites already use module-scoped loggers via logging.getLogger(__name__).
Remove stale mypy overrides that are no longer needed: - prometheus_client now ships py.typed - All four disallow_untyped_defs=False overrides pass strict Add missing type annotations to testutils and notifications.py to satisfy the now-strict config.
Replace `type: ignore[assignment]` with the narrower `type: ignore[method-assign]` on all test monkeypatching lines, as suggested by mypy 1.20. Enable warn_unused_ignores in mypy.ini to catch stale ignores going forward.
Add warn_return_any to catch implicit Any returns. Fix by: - Extracting dict values into typed locals (notifications.py) - Adding an else branch to exhaustive if/elif (apnstruncate.py) - Typing the dynamic getattr result (sygnal.py) - Typing yaml.safe_load result (sygnal.py) - Typing self.client as TestClient (testutils.py)
Enable UP (pyupgrade), B (bugbear), C4 (comprehensions), SIM (simplify), RUF (ruff-specific), PIE, and RSE rule sets. Key changes: - Modernize type annotations to Python 3.11+ syntax (dict, list, X | Y instead of Dict, List, Union) - Remove utf-8 coding declarations - Add `from err` to raise-in-except blocks (B904) - Merge nested with statements (SIM117) - Annotate mutable class defaults with ClassVar (RUF012) - Replace contextlib.suppress for try/except/pass (SIM105) - Simplify dict comprehension and string formatting
No longer used after the Twisted proxy infrastructure was removed.
6c3b661 to
abb4bab
Compare
bc34152 to
dce869b
Compare
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.
Summary
logger.warn()withlogger.warning()disallow_untyped_defsnow passes on all modules)type: ignorecomments to specific error codes and enablewarn_unused_ignoreswarn_return_anyin mypy and fix all violationstarget-versionfrom ruff config (inferred fromrequires-python)dictnotDict,X | YnotUnion)from errto raise-in-except blocks, merge nestedwithstatements, annotateClassVarProxyConnectErrorexception class (unused after Twisted removal)# -*- coding: utf-8 -*-declarations (unnecessary since Python 3)Notes
_choppable_getinapnstruncate.pynow raisesValueErrorinstead of implicitly returningNonefor unknown choppable types. The branches are exhaustive so this is unreachable in practice.warn_return_any = Falseforsygnal.apnstruncatemodule — needed due todict[str, Any]access patterns.PERF203(try-except in loop) is suppressed — the loops have intentional error handling.Test plan
uv run mypy sygnal/ tests/passes with zero errorsuv run ruff check sygnal/ tests/passesuv run pytest tests/— 55 tests pass