Skip to content

Commit 43a9ab0

Browse files
authored
Always use TypeAlias when assigning to Any (#8021)
1 parent a2ba0c8 commit 43a9ab0

File tree

17 files changed

+65
-45
lines changed

17 files changed

+65
-45
lines changed

stdlib/distutils/command/check.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from typing import Any
2+
from typing_extensions import TypeAlias
23

34
from ..cmd import Command
45

5-
_Reporter = Any # really docutils.utils.Reporter
6+
_Reporter: TypeAlias = Any # really docutils.utils.Reporter
67

78
# Only defined if docutils is installed.
89
class SilentReporter(_Reporter):

stdlib/logging/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,8 @@ class PercentStyle: # undocumented
876876
def format(self, record: Any) -> str: ...
877877

878878
class StrFormatStyle(PercentStyle): # undocumented
879-
fmt_spec = Any
880-
field_spec = Any
879+
fmt_spec: Pattern[str]
880+
field_spec: Pattern[str]
881881

882882
class StringTemplateStyle(PercentStyle): # undocumented
883883
_tpl: Template

stdlib/unittest/mock.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,13 @@ class _SpecState:
440440

441441
def mock_open(mock: Any | None = ..., read_data: Any = ...) -> Any: ...
442442

443-
PropertyMock = Any
443+
class PropertyMock(Mock):
444+
if sys.version_info >= (3, 8):
445+
def __get__(self: Self, obj: _T, obj_type: type[_T] | None = ...) -> Self: ...
446+
else:
447+
def __get__(self: Self, obj: _T, obj_type: type[_T] | None) -> Self: ...
448+
449+
def __set__(self, obj: Any, value: Any) -> None: ...
444450

445451
if sys.version_info >= (3, 7):
446452
def seal(mock: Any) -> None: ...

stubs/SQLAlchemy/sqlalchemy/ext/mypy/apply.pyi

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from typing import Any
2+
from typing_extensions import TypeAlias
23

34
from . import util
45

5-
AssignmentStmt = Any # from mypy.nodes
6-
NameExpr = Any # from mypy.nodes
7-
StrExpr = Any # from mypy.nodes
8-
SemanticAnalyzerPluginInterface = Any # from mypy.plugin
9-
ProperType = Any # from mypy.types
6+
AssignmentStmt: TypeAlias = Any # from mypy.nodes
7+
NameExpr: TypeAlias = Any # from mypy.nodes
8+
StrExpr: TypeAlias = Any # from mypy.nodes
9+
SemanticAnalyzerPluginInterface: TypeAlias = Any # from mypy.plugin
10+
ProperType: TypeAlias = Any # from mypy.types
1011

1112
def apply_mypy_mapped_attr(
1213
cls, api: SemanticAnalyzerPluginInterface, item: NameExpr | StrExpr, attributes: list[util.SQLAlchemyAttribute]

stubs/SQLAlchemy/sqlalchemy/ext/mypy/decl_class.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from typing import Any
2+
from typing_extensions import TypeAlias
23

34
from . import util
45

5-
SemanticAnalyzerPluginInterface = Any # from mypy.plugin
6+
SemanticAnalyzerPluginInterface: TypeAlias = Any # from mypy.plugin
67

78
def scan_declarative_assignments_and_apply_types(
89
cls, api: SemanticAnalyzerPluginInterface, is_mixin_scan: bool = ...

stubs/SQLAlchemy/sqlalchemy/ext/mypy/infer.pyi

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
from collections.abc import Sequence
22
from typing import Any
3+
from typing_extensions import TypeAlias
34

4-
AssignmentStmt = Any # from mypy.nodes
5-
Expression = Any # from mypy.nodes
6-
RefExpr = Any # from mypy.nodes
7-
TypeInfo = Any # from mypy.nodes
8-
Var = Any # from mypy.nodes
9-
StrExpr = Any # from mypy.nodes
10-
SemanticAnalyzerPluginInterface = Any # from mypy.plugin
11-
ProperType = Any # from mypy.types
5+
AssignmentStmt: TypeAlias = Any # from mypy.nodes
6+
Expression: TypeAlias = Any # from mypy.nodes
7+
RefExpr: TypeAlias = Any # from mypy.nodes
8+
TypeInfo: TypeAlias = Any # from mypy.nodes
9+
Var: TypeAlias = Any # from mypy.nodes
10+
StrExpr: TypeAlias = Any # from mypy.nodes
11+
SemanticAnalyzerPluginInterface: TypeAlias = Any # from mypy.plugin
12+
ProperType: TypeAlias = Any # from mypy.types
1213

1314
def infer_type_from_right_hand_nameexpr(
1415
api: SemanticAnalyzerPluginInterface,

stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from collections.abc import Callable
22
from typing import Any
3+
from typing_extensions import TypeAlias
34

4-
MypyFile = Any # from mypy.nodes
5-
AttributeContext = Any # from mypy.plugin
6-
ClassDefContext = Any # from mypy.plugin
7-
DynamicClassDefContext = Any # from mypy.plugin
8-
Plugin = Any # from mypy.plugin
9-
Type = Any # from mypy.types
5+
MypyFile: TypeAlias = Any # from mypy.nodes
6+
AttributeContext: TypeAlias = Any # from mypy.plugin
7+
ClassDefContext: TypeAlias = Any # from mypy.plugin
8+
DynamicClassDefContext: TypeAlias = Any # from mypy.plugin
9+
Plugin: TypeAlias = Any # from mypy.plugin
10+
Type: TypeAlias = Any # from mypy.types
1011

1112
class SQLAlchemyPlugin(Plugin):
1213
def get_dynamic_class_hook(self, fullname: str) -> Callable[[DynamicClassDefContext], None] | None: ...

stubs/SQLAlchemy/sqlalchemy/util/_concurrency_py3k.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import asyncio as asyncio
22
from collections.abc import Callable, Coroutine
33
from typing import Any
4+
from typing_extensions import TypeAlias
45

56
from .langhelpers import memoized_property
67

7-
_greenlet = Any # actually greenlet.greenlet
8+
_greenlet: TypeAlias = Any # actually greenlet.greenlet
89

910
def is_exit_exception(e): ...
1011

stubs/characteristic/characteristic/__init__.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ def with_init(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ...
77
def immutable(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ...
88
def strip_leading_underscores(attribute_name: AnyStr) -> AnyStr: ...
99

10-
NOTHING = Any
10+
class _Nothing: ...
11+
12+
NOTHING: _Nothing
1113

1214
_T = TypeVar("_T")
1315

stubs/ldap3/ldap3/protocol/microsoft.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from typing import Any
2+
from typing_extensions import TypeAlias
23

34
# Enable when pyasn1 gets stubs:
45
# from pyasn1.type.univ import Sequence
5-
Sequence = Any
6+
Sequence: TypeAlias = Any
67

78
class SicilyBindResponse(Sequence):
89
tagSet: Any

0 commit comments

Comments
 (0)