Skip to content

Commit 7c0770d

Browse files
authored
Merge branch 'main' into mailbox-improvements
2 parents 6504bdd + 8c7256c commit 7c0770d

File tree

315 files changed

+4154
-2473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

315 files changed

+4154
-2473
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ jobs:
6262
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
6363
fi
6464
- name: Run mypy_test.py
65-
run: |
66-
# python-version can sometimes be pinned to a specific version or to "-dev", but
67-
# mypy understands only X.Y version numbers.
68-
MYPY_PY_VERSION=$(echo ${{ matrix.python-version }} | cut -d - -f 1 | cut -d . -f 1-2)
69-
python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${MYPY_PY_VERSION}
65+
run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }}
7066

7167
regression-tests:
7268
name: "mypy: Run test cases"
@@ -75,9 +71,7 @@ jobs:
7571
- uses: actions/checkout@v5
7672
- uses: actions/setup-python@v6
7773
with:
78-
# Use py311 for now, as py312 seems to be around 30s slower in CI
79-
# TODO: figure out why that is (#11590)
80-
python-version: "3.11"
74+
python-version: "3.14"
8175
- uses: astral-sh/setup-uv@v6
8276
with:
8377
version-file: "requirements-tests.txt"

pyproject.toml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ exclude = [
2626
]
2727

2828
[tool.ruff.lint]
29+
future-annotations = true
2930
# Disable all rules on test cases by default:
3031
# test cases often deliberately contain code
3132
# that might not be considered idiomatic or modern.
@@ -69,15 +70,22 @@ select = [
6970
# Only include flake8-annotations rules that are autofixable. Otherwise leave this to mypy+pyright
7071
"ANN2",
7172
# Most refurb rules are in preview and can be opinionated,
72-
# consider them individually as they come out of preview (last check: 0.8.4)
73+
# consider them individually as they come out of preview (last check: 0.13.1)
7374
"FURB105", # Unnecessary empty string passed to `print`
75+
"FURB116", # Replace `{function_name}` call with `{display}`
76+
"FURB122", # Use of `{}.write` in a for loop
7477
"FURB129", # Instead of calling `readlines()`, iterate over file object directly
78+
"FURB132", # Use `{suggestion}` instead of `check` and `remove`
7579
"FURB136", # Replace `if` expression with `{min_max}` call
80+
"FURB157", # Verbose expression in `Decimal` constructor
81+
"FURB162", # Unnecessary timezone replacement with zero offset
82+
"FURB166", # Use of `int` with explicit `base={base}` after removing prefix
7683
"FURB167", # Use of regular expression alias `re.{}`
7784
"FURB168", # Prefer `is` operator over `isinstance` to check if an object is `None`
7885
"FURB169", # Compare the identities of `{object}` and None instead of their respective types
7986
"FURB177", # Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups
8087
"FURB187", # Use of assignment of `reversed` on list `{name}`
88+
"FURB188", # Prefer `str.removeprefix()` over conditionally replacing with slice.
8189
# Used for lint.flake8-import-conventions.aliases
8290
"ICN001", # `{name}` should be imported as `{asname}`
8391
# PYI: only enable rules that have autofixes and that we always want to fix (even manually),
@@ -89,6 +97,7 @@ select = [
8997
"PYI014", # Only simple default values allowed for arguments
9098
"PYI015", # Only simple default values allowed for assignments
9199
"PYI016", # Duplicate union member `{}`
100+
"PYI018", # Private `{type_var_like_kind}` `{type_var_like_name}` is never used
92101
"PYI019", # Methods like `{method_name}` should return `Self` instead of a custom `TypeVar`
93102
"PYI020", # Quoted annotations should not be included in stubs
94103
"PYI025", # Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin
@@ -99,7 +108,8 @@ select = [
99108
"PYI044", # `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics
100109
"PYI055", # Multiple `type[T]` usages in a union. Combine them into one, e.g., `type[{union_str}]`.
101110
"PYI058", # Use `{return_type}` as the return value for simple `{method}` methods
102-
# "PYI061", # TODO: Enable when out of preview
111+
# "PYI059", # TODO: Add when dropping Python 3.9 support
112+
"PYI061", # Use `None` rather than `Literal[None]`
103113
"PYI062", # Duplicate literal member `{}`
104114
"PYI064", # `Final[Literal[{literal}]]` can be replaced with a bare Final
105115
# flake8-simplify, excluding rules that can reduce performance or readability due to long line formatting
@@ -124,6 +134,7 @@ select = [
124134
"SIM223", # Use `{expr}` instead of `{replaced}`
125135
"SIM300", # Yoda condition detected
126136
"SIM401", # Use `{contents}` instead of an if block
137+
"SIM905", # Consider using a list literal instead of `str.{}`
127138
"SIM910", # Use `{expected}` instead of `{actual}` (dict-get-with-none-default)
128139
"SIM911", # Use `{expected}` instead of `{actual}` (zip-dict-keys-and-values)
129140
# Don't include TC rules that create a TYPE_CHECKING block or stringifies annotations
@@ -159,7 +170,7 @@ ignore = [
159170
# see https://github.com/astral-sh/ruff/issues/6465
160171
"E721", # Do not compare types, use `isinstance()`
161172
# Highly opinionated, and it's often necessary to violate it
162-
"PLC0415", # `import` should be at the top-level of a file
173+
"PLC0415", # `import` should be at the top-level of a file
163174
# Leave the size and complexity of tests to human interpretation
164175
"PLR09", # Too many ...
165176
# Too many magic number "2" that are preferable inline. https://github.com/astral-sh/ruff/issues/10009
@@ -175,7 +186,6 @@ ignore = [
175186
"TD003", # Missing issue link for this TODO
176187
# Mostly from scripts and tests, it's ok to have messages passed directly to exceptions
177188
"TRY003", # Avoid specifying long messages outside the exception class
178-
"PLC0205", # Sometimes __slots__ really is a string at runtime
179189
###
180190
# False-positives, but already checked by type-checkers
181191
###
@@ -206,6 +216,8 @@ ignore = [
206216
# Most pep8-naming rules don't apply for third-party stubs like typeshed.
207217
# N811 to N814 could apply, but we often use them to disambiguate a name whilst making it look like a more common one
208218
"N8", # pep8-naming
219+
# Sometimes __slots__ really is a string at runtime
220+
"PLC0205", # Class `__slots__` should be a non-string iterable
209221
# Stubs are allowed to use private variables (pyright's reportPrivateUsage is also disabled)
210222
"PLC2701", # Private name import from external module
211223
# Names in stubs should match implementation

pyrightconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
// No effect in stubs
2929
"reportMissingSuperCall": "none",
3030
"reportUninitializedInstanceVariable": "none",
31-
// stdlib stubs trigger reportShadowedImports
32-
"reportShadowedImports": "none",
3331
// Stubs are allowed to use private variables
3432
"reportPrivateUsage": "none",
3533
// Stubs don't need the actual modules to be installed

pyrightconfig.scripts_and_tests.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"reportImplicitStringConcatenation": "none",
1515
// Extra strict settings
1616
"reportMissingModuleSource": "error",
17-
"reportShadowedImports": "error",
1817
"reportCallInDefaultInitializer": "error",
1918
"reportPropertyTypeMismatch": "error",
2019
"reportUninitializedInstanceVariable": "error",

pyrightconfig.stricter.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"stubs/boltons",
3131
"stubs/braintree",
3232
"stubs/cffi",
33+
"stubs/colorful",
3334
"stubs/dateparser",
3435
"stubs/defusedxml",
3536
"stubs/docker",
@@ -79,7 +80,6 @@
7980
"stubs/PyMySQL",
8081
"stubs/python-dateutil",
8182
"stubs/python-jose",
82-
"stubs/pytz/pytz/lazy.pyi",
8383
"stubs/pywin32",
8484
"stubs/PyYAML",
8585
"stubs/reportlab",
@@ -88,6 +88,7 @@
8888
"stubs/seaborn",
8989
"stubs/setuptools/setuptools",
9090
"stubs/shapely",
91+
"stubs/simple-websocket",
9192
"stubs/tensorflow",
9293
"stubs/tqdm",
9394
"stubs/vobject",
@@ -107,8 +108,6 @@
107108
// No effect in stubs
108109
"reportMissingSuperCall": "none",
109110
"reportUninitializedInstanceVariable": "none",
110-
// stdlib stubs trigger reportShadowedImports
111-
"reportShadowedImports": "none",
112111
// Stubs are allowed to use private variables
113112
"reportPrivateUsage": "none",
114113
// Stubs don't need the actual modules to be installed

pyrightconfig.testcases.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
],
77
"typeCheckingMode": "strict",
88
// Extra strict settings
9-
"reportShadowedImports": "error", // Don't accidentally name a file something that shadows stdlib
109
"reportImplicitStringConcatenation": "error",
1110
"reportUninitializedInstanceVariable": "error",
1211
"reportUnnecessaryTypeIgnoreComment": "error",

scripts/stubsabot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def __str__(self) -> str:
161161
@dataclass
162162
class Remove:
163163
distribution: str
164-
reason: str
164+
reason: Literal["ships py.typed file", "unmaintained"]
165165
links: dict[str, str]
166166

167167
def __str__(self) -> str:
@@ -171,7 +171,7 @@ def __str__(self) -> str:
171171
@dataclass
172172
class NoUpdate:
173173
distribution: str
174-
reason: str
174+
reason: Literal["obsolete", "no longer updated", "up to date"]
175175

176176
def __str__(self) -> str:
177177
return f"{colored('skipping', 'green')} ({self.reason})"
@@ -642,7 +642,7 @@ async def determine_action_no_error_handling(
642642
"Typeshed release": f"{pypi_info.pypi_root}",
643643
"Typeshed stubs": f"https://github.com/{TYPESHED_OWNER}/typeshed/tree/main/stubs/{stub_info.distribution}",
644644
}
645-
return Remove(stub_info.distribution, reason="older than 6 months", links=links)
645+
return Remove(stub_info.distribution, reason="ships py.typed file", links=links)
646646
else:
647647
return NoUpdate(stub_info.distribution, "obsolete")
648648
if stub_info.no_longer_updated:
@@ -654,7 +654,7 @@ async def determine_action_no_error_handling(
654654
"Typeshed release": f"{pypi_info.pypi_root}",
655655
"Typeshed stubs": f"https://github.com/{TYPESHED_OWNER}/typeshed/tree/main/stubs/{stub_info.distribution}",
656656
}
657-
return Remove(stub_info.distribution, reason="no longer updated", links=links)
657+
return Remove(stub_info.distribution, reason="unmaintained", links=links)
658658
else:
659659
return NoUpdate(stub_info.distribution, "no longer updated")
660660

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ asyncio.locks.Condition.release
237237
builtins.memoryview.__contains__ # C type that implements __getitem__
238238
builtins.reveal_locals # Builtins that type checkers pretends exist
239239
builtins.reveal_type # Builtins that type checkers pretends exist
240-
builtins.type.__dict__ # read-only but not actually a property; stubtest thinks it's a mutable attribute.
241240

242241
# The following CodecInfo properties are added in __new__
243242
codecs.CodecInfo.decode

stdlib/@tests/stubtest_allowlists/darwin.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
(fcntl.F_SETLEASE)? # GNU extension
1111

1212

13+
# =======
14+
# <= 3.14
15+
# =======
16+
17+
# Added in Python 3.9.25, 3.10.20, 3.11.15, 3.12.13, 3.13.10, 3.14.1 (parameter `scripting`)
18+
html.parser.HTMLParser.__init__
19+
20+
1321
# ==========================================
1422
# Modules that do not exist on MacOS systems
1523
# ==========================================
@@ -45,9 +53,6 @@ multiprocessing.popen_spawn_win32 # exists on Darwin but fails to import
4553
readline.append_history_file # Only available if compiled with GNU readline, not editline
4654
select.poll # Actually a function; we have a class so it can be used as a type
4755

48-
# Some of these exist on non-windows, but they are useless and this is not intended
49-
stat.FILE_ATTRIBUTE_[A-Z_]+
50-
5156
tkinter.Tk.createfilehandler # Methods that come from __getattr__() at runtime
5257
tkinter.Tk.deletefilehandler # Methods that come from __getattr__() at runtime
5358

stdlib/@tests/stubtest_allowlists/linux-py310.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# =======
2+
# <= 3.14
3+
# =======
4+
5+
# Added in Python 3.10.20 (parameter `scripting`)
6+
html.parser.HTMLParser.__init__
7+
8+
19
# =============================================================
210
# Allowlist entries that cannot or should not be fixed; <= 3.12
311
# =============================================================

0 commit comments

Comments
 (0)