Skip to content

Commit 62a983d

Browse files
h-joocopybara-github
authored andcommitted
Add type annotations to abstract/class_mixin.py and correct / add type annotations that starts to break by the change
PiperOrigin-RevId: 694468407
1 parent 2510d70 commit 62a983d

2 files changed

Lines changed: 102 additions & 57 deletions

File tree

pytype/abstract/_classes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
from pytype.abstract import _function_base # pylint: disable=g-bad-import-order,g-import-not-at-top
2828
from pytype.abstract import _interpreter_function # pylint: disable=g-bad-import-order,g-import-not-at-top
2929
from pytype.abstract import _typing # pylint: disable=g-bad-import-order,g-import-not-at-top
30-
from pytype.abstract import abstract as _abstract # pylint: disable=g-import-not-at-top, g-bad-import-order
30+
from pytype.abstract import abstract as _abstract # pylint: disable=g-import-not-at-top,g-bad-import-order
3131
else:
32-
_abstract = abstract_utils._abstract # pylint: disable=protected-access
32+
_abstract = abstract_utils._abstract # pylint: disable=protected-access,g-import-not-at-top,g-bad-import-order
3333

3434
log: logging.Logger = logging.getLogger(__name__)
3535

@@ -130,7 +130,7 @@ def __init__(
130130
name: str,
131131
bases: list[cfg.Variable],
132132
members: dict[str, cfg.Variable],
133-
cls: _base.BaseValue,
133+
cls: class_mixin.Class,
134134
first_opcode: opcodes.Opcode | None,
135135
undecorated_methods: class_mixin.FunctionMapType | None,
136136
ctx: "context.Context",
@@ -332,7 +332,7 @@ def instantiate(
332332
container: (
333333
_instance_base.SimpleValue | abstract_utils.DummyContainer | None
334334
) = None,
335-
):
335+
) -> cfg.Variable:
336336
if self.ctx.vm.current_opcode:
337337
return self._new_instance(container, node, None).to_variable(node)
338338
else:
@@ -609,9 +609,9 @@ def _new_instance(
609609
_instance_base.SimpleValue | abstract_utils.DummyContainer | None
610610
),
611611
node: cfg.CFGNode,
612-
args: function.Args,
612+
args: function.Args | None,
613613
) -> _instance_base.Instance | _instances.Tuple:
614-
if self.full_name == "builtins.tuple" and args.is_empty():
614+
if self.full_name == "builtins.tuple" and args.is_empty(): # pytype: disable=attribute-error
615615
value = _instances.Tuple((), self.ctx)
616616
else:
617617
value = _instance_base.Instance(

0 commit comments

Comments
 (0)