Skip to content

Commit f1aede7

Browse files
authored
Manual changes of Any union to Incomplete in stubs folder (#9566)
- ClassVar[Any | None] - Missed previous changes due to alias - Manual review of leftover Any unions (`| Any` and `Any |`)
1 parent 95dc689 commit f1aede7

File tree

12 files changed

+32
-22
lines changed

12 files changed

+32
-22
lines changed

stubs/PyYAML/yaml/nodes.pyi

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ from typing import Any, ClassVar
22

33
from yaml.error import Mark
44

5+
# Any Unions: Avoid forcing the user to check for None when they know what Node was instantiated with
6+
# Using generics may be overkill without support for default Generics
7+
# Permissive Unions could also be useful here.
58
class Node:
69
tag: str
710
value: Any

stubs/PyYAML/yaml/representer.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import datetime
2-
from _typeshed import SupportsItems
2+
from _typeshed import Incomplete, SupportsItems
33
from collections.abc import Callable, Iterable, Mapping
44
from types import BuiltinFunctionType, FunctionType, ModuleType
55
from typing import Any, ClassVar, NoReturn, TypeVar
@@ -15,12 +15,12 @@ class RepresenterError(YAMLError): ...
1515
class BaseRepresenter:
1616
yaml_representers: ClassVar[dict[type[Any], Callable[[BaseRepresenter, Any], Node]]]
1717
yaml_multi_representers: ClassVar[dict[type[Any], Callable[[BaseRepresenter, Any], Node]]]
18-
default_style: str | Any
18+
default_style: str | Incomplete
1919
sort_keys: bool
2020
default_flow_style: bool
2121
represented_objects: dict[int, Node]
2222
object_keeper: list[Any]
23-
alias_key: int | Any
23+
alias_key: int | Incomplete
2424
def __init__(self, default_style: str | None = ..., default_flow_style: bool = ..., sort_keys: bool = ...) -> None: ...
2525
def represent(self, data) -> None: ...
2626
def represent_data(self, data) -> Node: ...

stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/array.pyi

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import Incomplete
12
from typing import Any as _Any
23

34
import sqlalchemy.types as sqltypes
@@ -13,7 +14,7 @@ class array(expression.ClauseList, expression.ColumnElement[_Any]):
1314
inherit_cache: bool
1415
type: _Any
1516
def __init__(self, clauses, **kw) -> None: ...
16-
def self_group(self, against: _Any | None = ...): ...
17+
def self_group(self, against: Incomplete | None = ...): ...
1718

1819
CONTAINS: _Any
1920
CONTAINED_BY: _Any
@@ -29,7 +30,9 @@ class ARRAY(sqltypes.ARRAY):
2930
as_tuple: _Any
3031
dimensions: _Any
3132
zero_indexes: _Any
32-
def __init__(self, item_type, as_tuple: bool = ..., dimensions: _Any | None = ..., zero_indexes: bool = ...) -> None: ...
33+
def __init__(
34+
self, item_type, as_tuple: bool = ..., dimensions: Incomplete | None = ..., zero_indexes: bool = ...
35+
) -> None: ...
3336
@property
3437
def hashable(self): ...
3538
@property

stubs/paho-mqtt/paho/mqtt/client.pyi

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import socket as _socket
33
import ssl as _ssl
44
import time
55
import types
6+
from _typeshed import Incomplete
67
from collections.abc import Callable
78
from typing import Any, Optional, TypeVar
89
from typing_extensions import TypeAlias
@@ -16,7 +17,7 @@ ssl: types.ModuleType | None
1617
socks: types.ModuleType | None
1718
time_func = time.monotonic
1819
HAVE_DNS: bool
19-
EAGAIN: int | Any
20+
EAGAIN: int | Incomplete
2021
MQTTv31: int
2122
MQTTv311: int
2223
MQTTv5: int
@@ -86,7 +87,7 @@ MQTT_BRIDGE: int
8687
MQTT_CLEAN_START_FIRST_ONLY: int
8788
sockpair_data: bytes
8889
_UserData: TypeAlias = Any
89-
_Socket: TypeAlias = _socket.socket | _ssl.SSLSocket | Any
90+
_Socket: TypeAlias = _socket.socket | _ssl.SSLSocket | Incomplete
9091
_Payload: TypeAlias = str | bytes | bytearray | float
9192
_ExtraHeader: TypeAlias = dict[str, str] | Callable[[dict[str, str]], dict[str, str]]
9293
_OnLog: TypeAlias = Callable[[Client, _UserData, int, str], object]

stubs/parsimonious/parsimonious/grammar.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import collections.abc
2+
from _typeshed import Incomplete
23
from collections import OrderedDict
34
from collections.abc import Callable, Mapping
45
from typing import Any, NoReturn
@@ -7,7 +8,7 @@ from parsimonious.expressions import _CALLABLE_TYPE, Expression, Literal, Lookah
78
from parsimonious.nodes import Node, NodeVisitor
89

910
class Grammar(OrderedDict[str, Expression]):
10-
default_rule: Expression | Any
11+
default_rule: Expression | Incomplete
1112
def __init__(self, rules: str = ..., **more_rules: Expression | _CALLABLE_TYPE) -> None: ...
1213
def default(self, rule_name: str) -> Grammar: ...
1314
def parse(self, text: str, pos: int = ...) -> Node: ...

stubs/parsimonious/parsimonious/nodes.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import Incomplete
12
from collections.abc import Callable, Iterator, Sequence
23
from re import Match
34
from typing import Any, NoReturn, TypeVar
@@ -27,7 +28,7 @@ class RegexNode(Node):
2728
class RuleDecoratorMeta(type): ...
2829

2930
class NodeVisitor(metaclass=RuleDecoratorMeta):
30-
grammar: Grammar | Any
31+
grammar: Grammar | Incomplete
3132
unwrapped_exceptions: tuple[type[BaseException], ...]
3233
def visit(self, node: Node) -> Any: ...
3334
def generic_visit(self, node: Node, visited_children: Sequence[Any]) -> NoReturn: ...

stubs/passlib/passlib/utils/handlers.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class HasRounds(GenericHandler):
110110
min_desired_rounds: ClassVar[int | None]
111111
max_desired_rounds: ClassVar[int | None]
112112
default_rounds: ClassVar[int | None]
113-
vary_rounds: ClassVar[Any | None]
113+
vary_rounds: ClassVar[Incomplete | None]
114114
rounds: int
115115
@classmethod
116116
def using( # type: ignore[override]

stubs/protobuf/google/protobuf/internal/well_known_types.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import SupportsItems
1+
from _typeshed import Incomplete, SupportsItems
22
from collections.abc import Iterable, Iterator, KeysView, Mapping, Sequence
33
from datetime import datetime, timedelta, tzinfo
44
from typing import Any as tAny
@@ -9,7 +9,7 @@ from google.protobuf import struct_pb2
99
class Any:
1010
type_url: tAny = ...
1111
value: tAny = ...
12-
def Pack(self, msg: tAny, type_url_prefix: str = ..., deterministic: tAny | None = ...) -> None: ...
12+
def Pack(self, msg: tAny, type_url_prefix: str = ..., deterministic: Incomplete | None = ...) -> None: ...
1313
def Unpack(self, msg: tAny) -> bool: ...
1414
def TypeName(self) -> str: ...
1515
def Is(self, descriptor: tAny) -> bool: ...
@@ -60,7 +60,7 @@ class FieldMask:
6060
) -> None: ...
6161

6262
class _FieldMaskTree:
63-
def __init__(self, field_mask: tAny | None = ...) -> None: ...
63+
def __init__(self, field_mask: Incomplete | None = ...) -> None: ...
6464
def MergeFromFieldMask(self, field_mask: tAny) -> None: ...
6565
def AddPath(self, path: tAny): ...
6666
def ToFieldMask(self, field_mask: tAny) -> None: ...

stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from _typeshed import StrOrBytesPath
66
from collections.abc import Generator, Iterable
7-
from typing import Any
7+
from types import CodeType
88
from typing_extensions import Literal
99

1010
from PyInstaller.building.build_main import Analysis
@@ -50,7 +50,7 @@ class PostGraphAPI:
5050
def __name__(self) -> str: ...
5151
# Compiled code. See stdlib.builtins.compile
5252
@property
53-
def co(self) -> Any: ...
53+
def co(self) -> CodeType: ...
5454
@property
5555
def analysis(self) -> Analysis: ...
5656
@property

stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
# We reference the vendored package rather than depending on the original untyped module.
33
# Anything not referenced in the PyInstaller stubs doesn't need to be added here.
44

5-
from typing import Any, Protocol
5+
from types import CodeType
6+
from typing import Protocol
67

78
class _SupportsGraphident(Protocol):
89
graphident: str
910

1011
# code, filename and packagepath are always initialized to None. But they can be given a value later.
1112
class Node:
1213
# Compiled code. See stdlib.builtins.compile
13-
code: Any | None
14+
code: CodeType | None
1415
filename: str | None
1516
graphident: str
1617
identifier: str

stubs/redis/redis/lock.pyi

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import Self
1+
from _typeshed import Incomplete, Self
22
from types import TracebackType
33
from typing import Any, ClassVar, Protocol
44

@@ -11,9 +11,9 @@ class Lock:
1111
LUA_EXTEND_SCRIPT: ClassVar[str]
1212
LUA_REACQUIRE_SCRIPT: ClassVar[str]
1313
LUA_RELEASE_SCRIPT: ClassVar[str]
14-
lua_extend: ClassVar[Any | None]
15-
lua_reacquire: ClassVar[Any | None]
16-
lua_release: ClassVar[Any | None]
14+
lua_extend: ClassVar[Incomplete | None]
15+
lua_reacquire: ClassVar[Incomplete | None]
16+
lua_release: ClassVar[Incomplete | None]
1717
local: _Local
1818
def __init__(
1919
self,

stubs/toml/toml/encoder.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TomlEncoder(Generic[_MappingT]):
1616
@overload
1717
def __init__(self: TomlEncoder[dict[str, Any]], _dict: type[dict[str, Any]] = ..., preserve: bool = ...) -> None: ...
1818
def get_empty_table(self) -> _MappingT: ...
19-
def dump_list(self, v: Iterable[object]) -> str: ...
19+
def dump_list(self, v: Iterable[Any]) -> str: ...
2020
def dump_inline_table(self, section: dict[str, Any] | Any) -> str: ...
2121
def dump_value(self, v: Any) -> str: ...
2222
def dump_sections(self, o: _MappingT, sup: str) -> tuple[str, _MappingT]: ...

0 commit comments

Comments
 (0)