8000 Merge branch 'main' into mypy-1.5 · python/typeshed@613e431 · GitHub
[go: up one dir, main page]

Skip to content

Commit 613e431

Browse files
committed
Merge branch 'main' into mypy-1.5
2 parents 59c2928 + 695d41f commit 613e431

File tree

124 files changed

+701
-504
lines changed

Some content is hidden

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

124 files changed

+701
-504
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{
44
"recommendations": [
55
"bierner.github-markdown-preview",
6+
"charliermarsh.ruff",
67
"editorconfig.editorconfig",
78
"ms-python.black-formatter",
89
"ms-python.flake8",
@@ -30,8 +31,6 @@
3031
"ms-python.autopep8",
3132
// Not using pylint
3233
"ms-python.pylint",
33-
// Not using Ruff
34-
"charliermarsh.ruff",
3534
// VSCode has implemented an optimized version
3635
"coenraads.bracket-pair-colorizer",
3736
"coenraads.bracket-pair-colorizer-2",

.vscode/settings.default.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*
66
* ⚠ Disclaimer: The typeshed team doesn't commit to maintaining this file. It exists purely for your ease of use.
77
*/
8-
// TODO: Add charliermarsh.ruff to unrecommended extensions
98
{
109
// Don't format on save for formatters we don't explicitely control
1110
"editor.formatOnSave": false,
@@ -22,7 +21,8 @@
2221
"pytype_exclude_list.txt": "properties"
2322
},
2423
"files.exclude": {
25-
"**/.mypy_cache": true
24+
"**/.*_cache": true, // mypy and Ruff cache
25+
"**/__pycache__": true
2626
},
2727
"files.insertFinalNewline": true,
2828
"files.trimFinalNewlines": true,
@@ -48,6 +48,7 @@
4848
"editor.formatOnSave": true,
4949
"editor.codeActionsOnSave": {
5050
"source.fixAll": true,
51+
// Allow isort or Ruff to organize imports
5152
"source.organizeImports": true
5253
}
5354
},
@@ -110,6 +111,10 @@
110111
"isort.check": true,
111112
"isort.importStrategy": "fromEnvironment",
112113
"black-formatter.importStrategy": "fromEnvironment",
114+
"ruff.importStrategy": "fromEnvironment",
115+
"ruff.fixAll": true,
116+
// Conflict between Ruff and isort
117+
"ruff.organizeImports": false,
113118
"evenBetterToml.formatter.alignComments": false,
114119
"evenBetterToml.formatter.alignEntries": false,
115120
"evenBetterToml.formatter.allowedBlankLines": 1,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ select = [
9797
]
9898

9999
[tool.typeshed]
100-
pyright_version = "1.1.320"
100+
pyright_version = "1.1.323"

requirements-tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ flake8-pyi==23.6.0; python_version >= "3.8" # must match .pre-commit-confi
99
isort==5.12.0; python_version >= "3.8" # must match .pre-commit-config.yaml
1010
mypy==1.5.1
1111
pre-commit-hooks==4.4.0 # must match .pre-commit-config.yaml
12-
pytype==2023.7.21; platform_system != "Windows" and python_version >= "3.8" and python_version < "3.11"
12+
pytype==2023.8.14; platform_system != "Windows" and python_version >= "3.8" and python_version < "3.11"
1313
ruff==0.0.280 # must match .pre-commit-config.yaml
1414

1515
# Libraries used by our various scripts.

stdlib/_typeshed/__init__.pyi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ Incomplete: TypeAlias = Any
3636
# To describe a function parameter that is unused and will work with anything.
3737
Unused: TypeAlias = object
3838

39+
# Used to mark arguments that default to a sentinel value. This prevents
40+
# stubtest from complaining about the default value not matching.
41+
#
42+
# def foo(x: int | None = sentinel) -> None: ...
43+
#
44+
# In cases where the sentinel object is exported and can be used by user code,
45+
# a construct like this is better:
46+
#
47+
# _SentinelType = NewType("_SentinelType", object)
48+
# sentinel: _SentinelType
49+
# def foo(x: int | None | _SentinelType = ...) -> None: ...
50+
sentinel = Any # noqa: Y026
51+
3952
# stable
4053
class IdentityFunction(Protocol):
4154
def __call__(self, __x: _T) -> _T: ...

stdlib/argparse.pyi

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
from _typeshed import sentinel
23
from collections.abc import Callable, Generator, Iterable, Sequence
34
from re import Pattern
45
from typing import IO, Any, Generic, NewType, NoReturn, Protocol, TypeVar, overload
@@ -334,7 +335,21 @@ class Action(_AttributeHolder):
334335
if sys.version_info >= (3, 9):
335336
def format_usage(self) -> str: ...
336337

337-
if sys.version_info >= (3, 9):
338+
if sys.version_info >= (3, 12):
339+
class BooleanOptionalAction(Action):
340+
def __init__(
341+
self,
342+
option_strings: Sequence[str],
343+
dest: str,
344+
default: _T | str | None = None,
345+
type: Callable[[str], _T] | FileType | None = sentinel, # noqa: Y011
346+
choices: Iterable[_T] | None = sentinel, # noqa: Y011
347+
required: bool = False,
348+
help: str | None = None,
349+
metavar: str | tuple[str, ...] | None = sentinel, # noqa: Y011
350+
) -> None: ...
351+
352+
elif sys.version_info >= (3, 9):
338353
class BooleanOptionalAction(Action):
339354
def __init__(
340355
self,

stdlib/enum.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import _typeshed
22
import sys
33
import types
44
from _typeshed import SupportsKeysAndGetItem, Unused
5-
from abc import ABCMeta
65
from builtins import property as _builtins_property
76
from collections.abc import Callable, Iterable, Iterator, Mapping
87
from typing import Any, Generic, TypeVar, overload
@@ -76,12 +75,8 @@ class _EnumDict(dict[str, Any]):
7675
@overload
7776
def update(self, members: Iterable[tuple[str, Any]], **more_members: Any) -> None: ...
7877

79-
# Note: EnumMeta actually subclasses type directly, not ABCMeta.
80-
# This is a temporary workaround to allow multiple creation of enums with builtins
81-
# such as str as mixins, which due to the handling of ABCs of builtin types, cause
82-
# spurious inconsistent metaclass structure. See #1595.
8378
# Structurally: Iterable[T], Reversible[T], Container[T] where T is the enum itself
84-
class EnumMeta(ABCMeta):
79+
class EnumMeta(type):
8580
if sys.version_info >= (3, 11):
8681
def __new__(
8782
metacls: type[_typeshed.Self],

stdlib/os/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ else:
912912
@property
913913
def si_code(self) -> int: ...
914914

915-
def waitid(__idtype: int, __ident: int, __options: int) -> waitid_result: ...
915+
def waitid(__idtype: int, __ident: int, __options: int) -> waitid_result | None: ...
916916

917917
def wait3(options: int) -> tuple[int, int, Any]: ...
918918
def wait4(pid: int, options: int) -> tuple[int, int, Any]: ...

stdlib/ssl.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,15 @@ class SSLContext:
436436
server_side: bool = False,
437437
do_handshake_on_connect: bool = True,
438438
suppress_ragged_eofs: bool = True,
439-
server_hostname: str | None = None,
439+
server_hostname: str | bytes | None = None,
440440
session: SSLSession | None = None,
441441
) -> SSLSocket: ...
442442
def wrap_bio(
443443
self,
444444
incoming: MemoryBIO,
445445
outgoing: MemoryBIO,
446446
server_side: bool = False,
447-
server_hostname: str | None = None,
447+
server_hostname: str | bytes | None = None,
448448
session: SSLSession | None = None,
449449
) -> SSLObject: ...
450450
def session_stats(self) -> dict[str, int]: ...

stdlib/typing.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,16 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
900900
def keys(self) -> dict_keys[str, object]: ...
901901
def values(self) -> dict_values[str, object]: ...
902902
if sys.version_info >= (3, 9):
903+
@overload
903904
def __or__(self, __value: typing_extensions.Self) -> typing_extensions.Self: ...
904-
def __ior__(self, __value: typing_extensions.Self) -> typing_extensions.Self: ...
905+
@overload
906+
def __or__(self, __value: dict[str, Any]) -> dict[str, object]: ...
907+
@overload
908+
def __ror__(self, __value: typing_extensions.Self) -> typing_extensions.Self: ...
909+
@overload
910+
def __ror__(self, __value: dict[str, Any]) -> dict[str, object]: ...
911+
# supposedly incompatible definitions of __or__ and __ior__
912+
def __ior__(self, __value: typing_extensions.Self) -> typing_extensions.Self: ... # type: ignore[misc]
905913

906914
@_final
907915
class ForwardRef:

stdlib/typing_extensions.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,16 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
233233
def values(self) -> dict_values[str, object]: ...
234234
def __delitem__(self, k: Never) -> None: ...
235235
if sys.version_info >= (3, 9):
236+
@overload
236237
def __or__(self, __value: Self) -> Self: ...
237-
def __ior__(self, __value: Self) -> Self: ...
238+
@overload
239+
def __or__(self, __value: dict[str, Any]) -> dict[str, object]: ...
240+
@overload
241+
def __ror__(self, __value: Self) -> Self: ...
242+
@overload
243+
def __ror__(self, __value: dict[str, Any]) -> dict[str, object]: ...
244+
# supposedly incompatible definitions of `__ior__` and `__or__`:
245+
def __ior__(self, __value: Self) -> Self: ... # type: ignore[misc]
238246

239247
# TypedDict is a (non-subscriptable) special form.
240248
TypedDict: object

stubs/JACK-Client/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version = "0.5.*"
2+
upstream_repository = "https://github.com/spatialaudio/jackclient-python"
23
# Requires a version of numpy with a `py.typed` file
34
requires = ["numpy>=1.20", "types-cffi"]
45

stubs/WebOb/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
version = "1.8.*"
2+
upstream_repository = "https://github.com/Pylons/webob"

stubs/aiofiles/@tests/stubtest_allowlist.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,3 @@ aiofiles.tempfile.temptypes.AsyncTemporaryDirectory.cleanup
9393
# Metaclass differs:
9494
aiofiles.base.AiofilesContextManager
9595
aiofiles.tempfile.AiofilesContextManagerTempDir
96-
97-
# Helper decorator, too complex to type
98-
aiofiles.os.wrap
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# At runtime, __all__ includes some items that are not available on Windows.
2+
# https://github.com/Tinche/aiofiles/pull/174
3+
aiofiles.os.__all__
4+
aiofiles.os.sendfile
5+
aiofiles.os.statvfs

stubs/aiofiles/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "23.1.*"
1+
version = "23.2.*"
22
upstream_repository = "https://github.com/Tinche/aiofiles"
33

44
[tool.stubtest]

stubs/aiofiles/aiofiles/os.pyi

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ from os import _ScandirIterator, stat_result
66
from typing import Any, AnyStr, overload
77

88
from aiofiles import ospath
9+
from aiofiles.ospath import wrap as wrap
10+
11+
__all__ = [
12+
"path",
13+
"stat",
14+
"rename",
15+
"renames",
16+
"replace",
17+
"remove",
18+
"unlink",
19+
"mkdir",
20+
"makedirs",
21+
"rmdir",
22+
"removedirs",
23+
"link",
24+
"symlink",
25+
"readlink",
26+
"listdir",
27+
"scandir",
28+
"access",
29+
"wrap",
30+
]
31+
32+
if sys.platform != "win32":
33+
__all__ += ["statvfs", "sendfile"]
934

1035
path = ospath
1136

@@ -90,8 +115,13 @@ async def listdir(path: StrPath | None, *, loop: AbstractEventLoop | None = ...,
90115
async def listdir(path: BytesPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[bytes]: ...
91116
@overload
92117
async def listdir(path: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[str]: ...
118+
async def access(
119+
path: FileDescriptorOrPath, mode: int, *, dir_fd: int | None = None, effective_ids: bool = False, follow_symlinks: bool = True
120+
) -> bool: ...
93121

94122
if sys.platform != "win32":
123+
from os import statvfs_result
124+
95125
@overload
96126
async def sendfile(
97127
out_fd: int, in_fd: int, offset: int | None, count: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...
@@ -109,3 +139,4 @@ if sys.platform != "win32":
109139
loop: AbstractEventLoop | None = ...,
110140
executor: Any = ...,
111141
) -> int: ... # FreeBSD and Mac OS X only
142+
async def statvfs(path: FileDescriptorOrPath) -> statvfs_result: ... # Unix only

stubs/aiofiles/aiofiles/ospath.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from _typeshed import FileDescriptorOrPath
22
from asyncio.events import AbstractEventLoop
3-
from typing import Any
3+
from collections.abc import Awaitable, Callable
4+
from typing import Any, TypeVar
45

6+
_R = TypeVar("_R")
7+
8+
def wrap(func: Callable[..., _R]) -> Callable[..., Awaitable[_R]]: ...
59
async def exists(path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
610
async def isfile(path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
711
async def isdir(s: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...

stubs/aiofiles/aiofiles/tempfile/temptypes.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ from _typeshed import Incomplete, OpenBinaryMode
22
from asyncio import AbstractEventLoop
33
from collections.abc import Generator, Iterable
44
from tempfile import TemporaryDirectory
5-
from types import coroutine as coroutine
65
from typing import TypeVar
76

87
from aiofiles.base import AsyncBase as AsyncBase

stubs/aiofiles/aiofiles/threadpool/utils.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from collections.abc import Callable
2-
from types import coroutine as coroutine
32
from typing import TypeVar
43

54
_T = TypeVar("_T", bound=type)

stubs/beautifulsoup4/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version = "4.12.*"
2+
upstream_repository = "https://git.launchpad.net/beautifulsoup/tree"
23
requires = ["types-html5lib"]
34
partial_stub = true
45

stubs/braintree/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version = "4.21.*"
2+
upstream_repository = "https://github.com/braintree/braintree_python"
23
partial_stub = true
34

45
[tool.stubtest]

stubs/cffi/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version = "1.15.*"
2+
upstream_repository = "https://foss.heptapod.net/pypy/cffi"
23
requires = ["types-setuptools"]
34

45
[tool.stubtest]

stubs/docopt/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
version = "0.6.*"
2+
upstream_repository = "https://github.com/docopt/docopt"

stubs/docutils/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version = "0.20.*"
2+
upstream_repository 741A = "https://sourceforge.net/p/docutils/code"
23
partial_stub = true
34

45
[tool.stubtest]

stubs/docutils/docutils/frontend.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@ class ConfigParser(RawConfigParser):
8181
def __getattr__(self, name: str) -> Incomplete: ...
8282

8383
class ConfigDeprecationWarning(DeprecationWarning): ...
84+
85+
def get_default_settings(*components) -> Values: ...

stubs/gdb/METADATA.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
version = "12.1.*"
2+
# This is the official web portal for GDB,
3+
# see https://sourceware.org/gdb/current/ for other ways of obtaining the source code.
4+
upstream_repository = "https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=tree"
25
extra_description = """\
36
Type hints for GDB's \
47
[Python API](https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html). \

stubs/hdbcli/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
version = "2.17.*"
2+
# upstream_repository = closed-source

stubs/humanfriendly/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version = "10.0.*"
2+
upstream_repository = "https://github.com/xolox/python-humanfriendly"
23

34
[tool.stubtest]
45
stubtest_requirements = ["docutils", "mock"]

stubs/ibm-db/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
version = "3.1.*"
2+
upstream_repository = "https://github.com/ibmdb/python-ibmdb"

stubs/influxdb-client/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "1.36.*"
1+
version = "1.37.*"
22
upstream_repository = "https://github.com/influxdata/influxdb-client-python"
33
requires = ["types-urllib3"]
44

stubs/influxdb-client/influxdb_client/domain/band_view_properties.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class BandViewProperties(ViewProperties):
88
discriminator: Incomplete
99
def __init__(
1010
self,
11+
adaptive_zoom_hide: bool | None = None,
1112
time_format: Incomplete | None = None,
1213
type: Incomplete | None = None,
1314
queries: Incomplete | None = None,
@@ -37,6 +38,7 @@ class BandViewProperties(ViewProperties):
3738
legend_opacity: Incomplete | None = None,
3839
legend_orientation_threshold: Incomplete | None = None,
3940
) -> None: ...
41+
adaptive_zoom_hide: bool | None
4042
@property
4143
def time_format(self): ...
4244
@time_format.setter

0 commit comments

Comments
 (0)
0