Skip to content

Commit 67daa7d

Browse files
Merge branch 'main' into with_3_overloads
2 parents 76ff58d + 4992a81 commit 67daa7d

File tree

10 files changed

+94
-36
lines changed

10 files changed

+94
-36
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -344,20 +344,20 @@ the latest mypy (`pip install -r requirements-tests.txt`) before running the scr
344344

345345
### Supported type system features
346346

347-
Since PEP 484 was accepted, there have been many other PEPs that added
348-
new features to the Python type system. In general, new features can
349-
be used in typeshed as soon as the PEP has been accepted and implemented
350-
and most type checkers support the new feature.
347+
Since [PEP 484](https://peps.python.org/pep-0484/) was accepted, there have been
348+
many other PEPs that added new features to the Python type system. In general,
349+
new features can be used in typeshed as soon as the PEP has been accepted and
350+
implemented and most type checkers support the new feature.
351351

352352
Supported features include:
353-
- [PEP 544](https://peps.python.org/pep-0544/) (Protocol)
353+
- [PEP 544](https://peps.python.org/pep-0544/) (`Protocol`)
354354
- [PEP 585](https://peps.python.org/pep-0585/) (builtin generics)
355-
- [PEP 586](https://peps.python.org/pep-0586/) (Literal)
356-
- [PEP 591](https://peps.python.org/pep-0591/) (Final/@final)
357-
- [PEP 589](https://peps.python.org/pep-0589/) (TypedDict)
355+
- [PEP 586](https://peps.python.org/pep-0586/) (`Literal`)
356+
- [PEP 591](https://peps.python.org/pep-0591/) (`Final`/`@final`)
357+
- [PEP 589](https://peps.python.org/pep-0589/) (`TypedDict`)
358358
- [PEP 604](https://peps.python.org/pep-0604/) (`Foo | Bar` union syntax)
359-
- [PEP 612](https://peps.python.org/pep-0612/) (ParamSpec)
360-
- [PEP 647](https://peps.python.org/pep-0647/) (TypeGuard):
359+
- [PEP 612](https://peps.python.org/pep-0612/) (`ParamSpec`)
360+
- [PEP 647](https://peps.python.org/pep-0647/) (`TypeGuard`):
361361
see [#5406](https://github.com/python/typeshed/issues/5406)
362362
- [PEP 655](https://peps.python.org/pep-0655/) (`Required` and `NotRequired`)
363363
- [PEP 673](https://peps.python.org/pep-0673/) (`Self`)

stdlib/@tests/stubtest_allowlists/linux.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ fcntl.I_[A-Z0-9_]+ # Platform differences that cannot be captured by the type s
2727
multiprocessing.popen_spawn_win32 # exists on Linux but fails to import
2828
select.poll # Actually a function; we have a class so it can be used as a type
2929

30+
# Bluetooth constants which aren't on the GitHub Actions runners, see #15207
31+
(_?socket\.AF_BLUETOOTH)?
32+
(_?socket\.BDADDR_ANY)?
33+
(_?socket\.BDADDR_LOCAL)?
34+
(_?socket\.BTPROTO_HCI)?
35+
(_?socket\.BTPROTO_L2CAP)?
36+
(_?socket\.BTPROTO_RFCOMM)?
37+
(_?socket\.BTPROTO_SCO)?
38+
3039
# These seem like they should be available on Linux, but they're not
3140
# on GitHub Actions runners for some reason.
3241
_?socket.IPX_TYPE

stdlib/_socket.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ if sys.platform != "linux":
587587

588588
has_ipv6: bool
589589

590-
if sys.platform != "darwin" and sys.platform != "linux":
590+
if sys.platform != "darwin":
591591
BDADDR_ANY: Final = "00:00:00:00:00:00"
592592
BDADDR_LOCAL: Final = "00:00:00:FF:FF:FF"
593593

@@ -660,16 +660,16 @@ if sys.platform == "darwin":
660660
PF_SYSTEM: Final[int]
661661
SYSPROTO_CONTROL: Final[int]
662662

663-
if sys.platform != "darwin" and sys.platform != "linux":
663+
if sys.platform != "darwin":
664664
AF_BLUETOOTH: Final[int]
665665

666-
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
666+
if sys.platform != "win32" and sys.platform != "darwin":
667667
# Linux and some BSD support is explicit in the docs
668668
# Windows and macOS do not support in practice
669669
BTPROTO_HCI: Final[int]
670670
BTPROTO_L2CAP: Final[int]
671671
BTPROTO_SCO: Final[int] # not in FreeBSD
672-
if sys.platform != "darwin" and sys.platform != "linux":
672+
if sys.platform != "darwin":
673673
BTPROTO_RFCOMM: Final[int]
674674

675675
if sys.platform == "linux":

stdlib/socket.pyi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,10 @@ if sys.platform != "win32":
519519

520520
__all__ += ["SO_BINDTODEVICE"]
521521

522-
if sys.platform != "darwin" and sys.platform != "linux":
522+
if sys.platform != "darwin":
523523
from _socket import BDADDR_ANY as BDADDR_ANY, BDADDR_LOCAL as BDADDR_LOCAL, BTPROTO_RFCOMM as BTPROTO_RFCOMM
524524

525+
if sys.platform != "darwin" and sys.platform != "linux":
525526
__all__ += ["BDADDR_ANY", "BDADDR_LOCAL", "BTPROTO_RFCOMM"]
526527

527528
if sys.platform == "darwin" and sys.version_info >= (3, 10):
@@ -969,9 +970,10 @@ if sys.platform != "linux":
969970
if sys.platform != "darwin" and sys.platform != "linux":
970971
__all__ += ["AF_BLUETOOTH"]
971972

972-
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
973+
if sys.platform != "win32" and sys.platform != "darwin":
973974
from _socket import BTPROTO_HCI as BTPROTO_HCI, BTPROTO_L2CAP as BTPROTO_L2CAP, BTPROTO_SCO as BTPROTO_SCO
974975

976+
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
975977
__all__ += ["BTPROTO_HCI", "BTPROTO_L2CAP", "BTPROTO_SCO"]
976978

977979
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
@@ -1131,7 +1133,7 @@ class AddressFamily(IntEnum):
11311133
AF_QIPCRTR = 42
11321134
if sys.platform != "linux":
11331135
AF_LINK = 33
1134-
if sys.platform != "darwin" and sys.platform != "linux":
1136+
if sys.platform != "darwin":
11351137
AF_BLUETOOTH = 32
11361138
if sys.platform == "win32" and sys.version_info >= (3, 12):
11371139
AF_HYPERV = 34
@@ -1186,7 +1188,7 @@ if sys.platform == "linux":
11861188

11871189
if sys.platform != "linux":
11881190
AF_LINK: Final = AddressFamily.AF_LINK
1189-
if sys.platform != "darwin" and sys.platform != "linux":
1191+
if sys.platform != "darwin":
11901192
AF_BLUETOOTH: Final = AddressFamily.AF_BLUETOOTH
11911193
if sys.platform == "win32" and sys.version_info >= (3, 12):
11921194
AF_HYPERV: Final = AddressFamily.AF_HYPERV

stubs/geopandas/geopandas/geodataframe.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class GeoDataFrame(GeoPandasBase, pd.DataFrame): # type: ignore[misc]
221221
self,
222222
path: str | os.PathLike[str] | SupportsWrite[Incomplete],
223223
index: bool | None = None,
224-
compression: Literal["snappy", "gzip", "brotli"] | None = "snappy",
224+
compression: Literal["snappy", "gzip", "brotli", "lz4", "zstd"] | None = "snappy",
225225
geometry_encoding: _GeomEncoding = "WKB",
226226
write_covering_bbox: bool = False,
227227
schema_version: str | None = None,

stubs/punq/punq/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Container:
8686
instance: _T | _Empty = ...,
8787
scope: Scope = Scope.transient,
8888
**kwargs: Any,
89-
): ...
89+
) -> Container: ...
9090
def resolve_all(self, service: type[_T] | str, **kwargs: Any) -> list[_T]: ...
9191
def resolve(self, service_key: type[_T] | str, **kwargs: Any) -> _T: ...
9292
def instantiate(self, service_key: type[_T] | str, **kwargs: Any) -> _T: ...

stubs/tensorflow/tensorflow/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ from tensorflow._aliases import (
2626
AnyArray,
2727
DTypeLike,
2828
IntArray,
29+
RaggedTensorLike,
2930
ScalarTensorCompatible,
3031
ShapeLike,
3132
Slice,
@@ -448,4 +449,5 @@ def transpose(
448449
def clip_by_value(
449450
t: Tensor | IndexedSlices, clip_value_min: TensorCompatible, clip_value_max: TensorCompatible, name: str | None = None
450451
) -> Tensor: ...
452+
def tile(input: RaggedTensorLike, multiples: Tensor, name: str | None = None) -> Tensor: ...
451453
def __getattr__(name: str): ... # incomplete module

stubs/tensorflow/tensorflow/keras/layers/__init__.pyi

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,4 +443,48 @@ class GaussianDropout(Layer[tf.Tensor, tf.Tensor]):
443443
name: str | None = None,
444444
) -> None: ...
445445

446+
class Activation(Layer[tf.Tensor, tf.Tensor]):
447+
def __init__(
448+
self,
449+
activation: _Activation = None,
450+
*,
451+
# **kwargs passed to Layer
452+
# **kwargs passed to Layer
453+
activity_regularizer: _Regularizer = None,
454+
trainable: bool = True,
455+
dtype: _LayerDtype | None = None,
456+
autocast: bool = True,
457+
name: str | None = None,
458+
) -> None: ...
459+
460+
class GlobalAveragePooling2D(Layer[tf.Tensor, tf.Tensor]):
461+
def __init__(
462+
self,
463+
data_format: Literal["channels_last", "channels_first"] | None = None,
464+
keepdims: bool = False,
465+
*,
466+
# **kwargs passed to Layer
467+
activity_regularizer: _Regularizer = None,
468+
trainable: bool = True,
469+
dtype: _LayerDtype | None = None,
470+
autocast: bool = True,
471+
name: str | None = None,
472+
) -> None: ...
473+
474+
class MaxPool2D(Layer[tf.Tensor, tf.Tensor]):
475+
def __init__(
476+
self,
477+
pool_size: int | tuple[int, int] = (2, 2),
478+
strides: int | tuple[int, int] | None = None,
479+
padding: Literal["valid", "same"] = "valid",
480+
data_format: Literal["channels_last", "channels_first"] | None = None,
481+
*,
482+
# **kwargs passed to Layer
483+
activity_regularizer: _Regularizer = None,
484+
trainable: bool = True,
485+
dtype: _LayerDtype | None = None,
486+
autocast: bool = True,
487+
name: str | None = None,
488+
) -> None: ...
489+
446490
def __getattr__(name: str): ... # incomplete module

tests/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ may require extra dependencies external to typeshed to be installed in your virt
2222
prior to running the test.
2323
You can list or install all of a stubs package's external dependencies using the following script:
2424
```bash
25-
(.venv3)$ python tests/get_external_stub_requirements.py <third_party_stub> # List external dependencies for <third_party_stub>
26-
(.venv3)$ python tests/get_external_stub_requirements.py <third_party_stub1> <third_party_stub2> # List external dependencies for <third_party_stub1> and <third_party_stub2>
27-
(.venv3)$ python tests/get_external_stub_requirements.py # List external dependencies for all third-party stubs in typeshed
28-
(.venv3)$ python scripts/install_all_third_party_dependencies.py # Install external dependencies for all third-party stubs in typeshed
25+
(.venv)$ python tests/get_external_stub_requirements.py <third_party_stub> # List external dependencies for <third_party_stub>
26+
(.venv)$ python tests/get_external_stub_requirements.py <third_party_stub1> <third_party_stub2> # List external dependencies for <third_party_stub1> and <third_party_stub2>
27+
(.venv)$ python tests/get_external_stub_requirements.py # List external dependencies for all third-party stubs in typeshed
28+
(.venv)$ python scripts/install_all_third_party_dependencies.py # Install external dependencies for all third-party stubs in typeshed
2929
```
3030

3131
## Run all tests for a specific stub
3232

3333
Run using:
3434
```bash
35-
(.venv3)$ python3 tests/runtests.py <stdlib-or-stubs>/<stub-to-test>
35+
(.venv)$ python3 tests/runtests.py <stdlib-or-stubs>/<stub-to-test>
3636
```
3737

3838
This script will run all tests below for a specific typeshed directory. If a
@@ -52,7 +52,7 @@ For more information, see the docs on [`stubtest_stdlib.py`](#stubtest_stdlibpy)
5252

5353
Run using:
5454
```bash
55-
(.venv3)$ python3 tests/mypy_test.py
55+
(.venv)$ python3 tests/mypy_test.py
5656
```
5757

5858
The test has two parts: running mypy on the stdlib stubs,
@@ -71,9 +71,9 @@ This test requires [Node.js](https://nodejs.org) to be installed. Although
7171
typeshed runs pyright in CI, it does not currently use this script. However,
7272
this script uses the same pyright version and configuration as the CI.
7373
```bash
74-
(.venv3)$ python3 tests/pyright_test.py # Check all files
75-
(.venv3)$ python3 tests/pyright_test.py stdlib/sys.pyi # Check one file
76-
(.venv3)$ python3 tests/pyright_test.py -p pyrightconfig.stricter.json # Check with the stricter config.
74+
(.venv)$ python3 tests/pyright_test.py # Check all files
75+
(.venv)$ python3 tests/pyright_test.py stdlib/sys.pyi # Check one file
76+
(.venv)$ python3 tests/pyright_test.py -p pyrightconfig.stricter.json # Check with the stricter config.
7777
```
7878

7979
`pyrightconfig.stricter.json` is a stricter configuration that enables additional
@@ -103,7 +103,7 @@ $ python3 tests/check_typeshed_structure.py
103103

104104
Run using
105105
```bash
106-
(.venv3)$ python3 tests/stubtest_stdlib.py
106+
(.venv)$ python3 tests/stubtest_stdlib.py
107107
```
108108

109109
This test compares the stdlib stubs against the objects at runtime. Because of
@@ -138,21 +138,21 @@ stubtest on.
138138

139139
Run using
140140
```bash
141-
(.venv3)$ python3 tests/stubtest_third_party.py
141+
(.venv)$ python3 tests/stubtest_third_party.py
142142
```
143143

144144
Similar to `stubtest_stdlib.py`, but tests the third party stubs. By default,
145145
it checks all third-party stubs, but you can provide the distributions to
146146
check on the command line:
147147

148148
```bash
149-
(.venv3)$ python3 tests/stubtest_third_party.py requests toml # check stubs/requests and stubs/toml
149+
(.venv)$ python3 tests/stubtest_third_party.py requests toml # check stubs/requests and stubs/toml
150150
```
151151

152152
If you have the runtime package installed in your local virtual environment, you can also run stubtest
153153
directly, with
154154
```bash
155-
(.venv3)$ MYPYPATH=<path-to-module-stubs> python3 -m mypy.stubtest \
155+
(.venv)$ MYPYPATH=<path-to-module-stubs> python3 -m mypy.stubtest \
156156
--custom-typeshed-dir <path-to-typeshed> \
157157
<third-party-module>
158158
```
@@ -203,7 +203,7 @@ configuration to properly validate Django-specific types during stubtest executi
203203

204204
Run using
205205
```bash
206-
(.venv3)$ python3 tests/typecheck_typeshed.py
206+
(.venv)$ python3 tests/typecheck_typeshed.py
207207
```
208208

209209
This is a small wrapper script that uses mypy to typecheck typeshed's own code in the

tests/REGRESSION.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ rather than `.pyi` files)
9999
is that the test cases cannot always use modern syntax for type hints.
100100
While we can use `from __future__ import annotations` to enable the use of
101101
modern typing syntax wherever possible,
102-
type checkers may (correctly) emit errors if PEP 604 syntax or PEP 585 syntax
103-
is used in a runtime context on lower versions of Python. For example:
102+
type checkers may (correctly) emit errors if [PEP 604](https://peps.python.org/pep-0604/)
103+
syntax or [PEP 585](https://peps.python.org/pep-0585/) syntax is used
104+
in a runtime context on lower versions of Python. For example:
104105

105106
```python
106107
from __future__ import annotations

0 commit comments

Comments
 (0)