Always use TypeAlias when assigning to Any (#8021)

This commit is contained in:
Alex Waygood
2022-06-06 02:16:20 +01:00
committed by GitHub
parent a2ba0c8a00
commit 43a9ab08d7
17 changed files with 65 additions and 45 deletions

View File

@@ -1,12 +1,13 @@
from typing import Any
from typing_extensions import TypeAlias
from . import util
AssignmentStmt = Any # from mypy.nodes
NameExpr = Any # from mypy.nodes
StrExpr = Any # from mypy.nodes
SemanticAnalyzerPluginInterface = Any # from mypy.plugin
ProperType = Any # from mypy.types
AssignmentStmt: TypeAlias = Any # from mypy.nodes
NameExpr: TypeAlias = Any # from mypy.nodes
StrExpr: TypeAlias = Any # from mypy.nodes
SemanticAnalyzerPluginInterface: TypeAlias = Any # from mypy.plugin
ProperType: TypeAlias = Any # from mypy.types
def apply_mypy_mapped_attr(
cls, api: SemanticAnalyzerPluginInterface, item: NameExpr | StrExpr, attributes: list[util.SQLAlchemyAttribute]

View File

@@ -1,8 +1,9 @@
from typing import Any
from typing_extensions import TypeAlias
from . import util
SemanticAnalyzerPluginInterface = Any # from mypy.plugin
SemanticAnalyzerPluginInterface: TypeAlias = Any # from mypy.plugin
def scan_declarative_assignments_and_apply_types(
cls, api: SemanticAnalyzerPluginInterface, is_mixin_scan: bool = ...

View File

@@ -1,14 +1,15 @@
from collections.abc import Sequence
from typing import Any
from typing_extensions import TypeAlias
AssignmentStmt = Any # from mypy.nodes
Expression = Any # from mypy.nodes
RefExpr = Any # from mypy.nodes
TypeInfo = Any # from mypy.nodes
Var = Any # from mypy.nodes
StrExpr = Any # from mypy.nodes
SemanticAnalyzerPluginInterface = Any # from mypy.plugin
ProperType = Any # from mypy.types
AssignmentStmt: TypeAlias = Any # from mypy.nodes
Expression: TypeAlias = Any # from mypy.nodes
RefExpr: TypeAlias = Any # from mypy.nodes
TypeInfo: TypeAlias = Any # from mypy.nodes
Var: TypeAlias = Any # from mypy.nodes
StrExpr: TypeAlias = Any # from mypy.nodes
SemanticAnalyzerPluginInterface: TypeAlias = Any # from mypy.plugin
ProperType: TypeAlias = Any # from mypy.types
def infer_type_from_right_hand_nameexpr(
api: SemanticAnalyzerPluginInterface,

View File

@@ -1,12 +1,13 @@
from collections.abc import Callable
from typing import Any
from typing_extensions import TypeAlias
MypyFile = Any # from mypy.nodes
AttributeContext = Any # from mypy.plugin
ClassDefContext = Any # from mypy.plugin
DynamicClassDefContext = Any # from mypy.plugin
Plugin = Any # from mypy.plugin
Type = Any # from mypy.types
MypyFile: TypeAlias = Any # from mypy.nodes
AttributeContext: TypeAlias = Any # from mypy.plugin
ClassDefContext: TypeAlias = Any # from mypy.plugin
DynamicClassDefContext: TypeAlias = Any # from mypy.plugin
Plugin: TypeAlias = Any # from mypy.plugin
Type: TypeAlias = Any # from mypy.types
class SQLAlchemyPlugin(Plugin):
def get_dynamic_class_hook(self, fullname: str) -> Callable[[DynamicClassDefContext], None] | None: ...

View File

@@ -1,10 +1,11 @@
import asyncio as asyncio
from collections.abc import Callable, Coroutine
from typing import Any
from typing_extensions import TypeAlias
from .langhelpers import memoized_property
_greenlet = Any # actually greenlet.greenlet
_greenlet: TypeAlias = Any # actually greenlet.greenlet
def is_exit_exception(e): ...