Skip to content

Commit

Permalink
Add type annotations to abstract/class_mixin.py
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 690586137
  • Loading branch information
h-joo authored and copybara-github committed Nov 8, 2024
1 parent 2510d70 commit 0b7a19d
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 57 deletions.
12 changes: 6 additions & 6 deletions pytype/abstract/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
from pytype.abstract import _function_base # pylint: disable=g-bad-import-order,g-import-not-at-top
from pytype.abstract import _interpreter_function # pylint: disable=g-bad-import-order,g-import-not-at-top
from pytype.abstract import _typing # pylint: disable=g-bad-import-order,g-import-not-at-top
from pytype.abstract import abstract as _abstract # pylint: disable=g-import-not-at-top, g-bad-import-order
from pytype.abstract import abstract as _abstract # pylint: disable=g-import-not-at-top,g-bad-import-order
else:
_abstract = abstract_utils._abstract # pylint: disable=protected-access
_abstract = abstract_utils._abstract # pylint: disable=protected-access,g-import-not-at-top,g-bad-import-order

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

Expand Down Expand Up @@ -130,7 +130,7 @@ def __init__(
name: str,
bases: list[cfg.Variable],
members: dict[str, cfg.Variable],
cls: _base.BaseValue,
cls: class_mixin.Class,
first_opcode: opcodes.Opcode | None,
undecorated_methods: class_mixin.FunctionMapType | None,
ctx: "context.Context",
Expand Down Expand Up @@ -332,7 +332,7 @@ def instantiate(
container: (
_instance_base.SimpleValue | abstract_utils.DummyContainer | None
) = None,
):
) -> cfg.Variable:
if self.ctx.vm.current_opcode:
return self._new_instance(container, node, None).to_variable(node)
else:
Expand Down Expand Up @@ -609,9 +609,9 @@ def _new_instance(
_instance_base.SimpleValue | abstract_utils.DummyContainer | None
),
node: cfg.CFGNode,
args: function.Args,
args: function.Args | None,
) -> _instance_base.Instance | _instances.Tuple:
if self.full_name == "builtins.tuple" and args.is_empty():
if self.full_name == "builtins.tuple" and args.is_empty(): # pytype: disable=attribute-error
value = _instances.Tuple((), self.ctx)
else:
value = _instance_base.Instance(
Expand Down
Loading

0 comments on commit 0b7a19d

Please sign in to comment.