Skip to content

Commit

Permalink
Improve typing of ClassDef private helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Jul 29, 2024
1 parent 590498d commit fb2fb36
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions astroid/nodes/scoped_nodes/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,11 @@ async def func(things):
"""


def _is_metaclass(klass, seen=None, context: InferenceContext | None = None) -> bool:
def _is_metaclass(
klass: ClassDef,
seen: set[str] | None = None,
context: InferenceContext | None = None,
) -> bool:
"""Return if the given class can be
used as a metaclass.
"""
Expand Down Expand Up @@ -1767,7 +1771,11 @@ def _is_metaclass(klass, seen=None, context: InferenceContext | None = None) ->
return False


def _class_type(klass, ancestors=None, context: InferenceContext | None = None):
def _class_type(
klass: ClassDef,
ancestors: set[str] | None = None,
context: InferenceContext | None = None,
):
"""return a ClassDef node type to differ metaclass and exception
from 'regular' classes
"""
Expand Down Expand Up @@ -1859,7 +1867,7 @@ def my_meth(self, arg):
:type: objectmodel.ClassModel
"""

_type = None
_type: Literal["class", "exception", "metaclass"] | None = None
_metaclass: NodeNG | None = None
_metaclass_hack = False
hide = False
Expand Down

0 comments on commit fb2fb36

Please sign in to comment.