Skip to content

Commit a3e02ff

Browse files
committed
Merge remote-tracking branch 'upstream/main' into ugprade-psutil-7-1
2 parents 129bd24 + b4b6330 commit a3e02ff

File tree

267 files changed

+3772
-1973
lines changed

Some content is hidden

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

267 files changed

+3772
-1973
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"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def foo(x: Incomplete | None) -> list[Incomplete]: ...
311311
### What to do when a project's documentation and implementation disagree
312312

313313
Type stubs are meant to be external type annotations for a given
314-
library. While they are useful documentation in its own merit, they
314+
library. While they are useful documentation in their own right, they
315315
augment the project's concrete implementation, not the project's
316316
documentation. Whenever you find them disagreeing, model the type
317317
information after the actual implementation and file an issue on the

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
## About
88

99
Typeshed contains external type annotations for the Python standard library
10-
and Python builtins, as well as third party packages as contributed by
10+
and Python builtins, as well as third-party packages that are contributed by
1111
people external to those projects.
1212

13-
This data can e.g. be used for static analysis, type checking, type inference,
13+
This data can, e.g., be used for static analysis, type checking, type inference,
1414
and autocompletion.
1515

1616
For information on how to use typeshed, read below. Information for
@@ -29,8 +29,8 @@ If you're just using a type checker (e.g. [mypy](https://github.com/python/mypy/
2929
[pyright](https://github.com/microsoft/pyright), or PyCharm's built-in type
3030
checker), as opposed to
3131
developing it, you don't need to interact with the typeshed repo at
32-
all: a copy of standard library part of typeshed is bundled with type checkers.
33-
And type stubs for third party packages and modules you are using can
32+
all: a copy of the standard library part of typeshed is bundled with type checkers.
33+
And type stubs for third-party packages and modules you are using can
3434
be installed from PyPI. For example, if you are using `html5lib` and `requests`,
3535
you can install the type stubs using
3636

@@ -70,7 +70,7 @@ package you're using, each with its own tradeoffs:
7070
type checking due to changes in the stubs.
7171

7272
Another risk of this strategy is that stubs often lag behind
73-
the package being stubbed. You might want to force the package being stubbed
73+
the package that is being stubbed. You might want to force the package being stubbed
7474
to a certain minimum version because it fixes a critical bug, but if
7575
correspondingly updated stubs have not been released, your type
7676
checking results may not be fully accurate.
@@ -119,6 +119,6 @@ a review of your type annotations or stubs outside of typeshed, head over to
119119
[our discussion forum](https://github.com/python/typing/discussions).
120120
For less formal discussion, try the typing chat room on
121121
[gitter.im](https://gitter.im/python/typing). Some typeshed maintainers
122-
are almost always present; feel free to find us there and we're happy
122+
are almost always present; feel free to find us there, and we're happy
123123
to chat. Substantive technical discussion will be directed to the
124124
issue tracker.

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",

requirements-tests.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Type checkers that we test our stubs against. These should always
22
# be pinned to a specific version to make failure reproducible.
33
mypy==1.18.2
4-
pyright==1.1.406
4+
pyright==1.1.407
55

66
# Libraries used by our various scripts.
77
aiohttp==3.12.15
@@ -19,7 +19,7 @@ termcolor>=2.3
1919
tomli==2.2.1; python_version < "3.11"
2020
tomlkit==0.13.3
2121
typing_extensions>=4.15.0rc1
22-
uv==0.8.22
22+
uv==0.9.6
2323

2424
# Utilities for typeshed infrastructure scripts.
2525
ts_utils @ file:lib

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

0 commit comments

Comments
 (0)