Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions returns/contrib/mypy/returns_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
"""

from collections.abc import Callable, Mapping
from typing import ClassVar, final
from typing import ClassVar, TypeAlias, final

from mypy.nodes import SymbolTableNode
from mypy.plugin import (
AttributeContext,
FunctionContext,
Expand All @@ -39,22 +38,16 @@
# ============

#: Type for a function hook.
_FunctionCallback = Callable[[FunctionContext], MypyType]

#: Type for a function hook that need a definition node.
_FunctionDefCallback = Callable[
[SymbolTableNode | None],
Callable[[FunctionContext], MypyType],
]
_FunctionCallback: TypeAlias = Callable[[FunctionContext], MypyType]

#: Type for attribute hook.
_AttributeCallback = Callable[[AttributeContext], MypyType]
_AttributeCallback: TypeAlias = Callable[[AttributeContext], MypyType]

#: Type for a method hook.
_MethodCallback = Callable[[MethodContext], MypyType]
_MethodCallback: TypeAlias = Callable[[MethodContext], MypyType]

#: Type for a method signature hook.
_MethodSigCallback = Callable[[MethodSigContext], CallableType]
_MethodSigCallback: TypeAlias = Callable[[MethodSigContext], CallableType]


# Interface
Expand Down