Skip to content

Commit 3e9f50e

Browse files
committed
Initialize FuncDef.arguments in deserialize
1 parent 737caed commit 3e9f50e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

mypy/nodes.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ def set_line(self,
641641
class FuncItem(FuncBase):
642642
"""Base class for nodes usable as overloaded function items."""
643643

644-
__slots__ = ('arguments', # Note that can be None if deserialized (type is a lie!)
644+
__slots__ = ('arguments', # Note that items can be None if deserialized (type is a lie!)
645645
'arg_names', # Names of arguments
646646
'arg_kinds', # Kinds of arguments
647647
'min_args', # Minimum number of arguments
@@ -657,7 +657,7 @@ class FuncItem(FuncBase):
657657
'expanded', # Variants of function with type variables with values expanded
658658
)
659659

660-
__deletable__ = ('arguments', 'max_pos', 'min_args')
660+
__deletable__ = ('max_pos', 'min_args')
661661

662662
def __init__(self,
663663
arguments: List[Argument],
@@ -770,8 +770,10 @@ def deserialize(cls, data: JsonDict) -> 'FuncDef':
770770
# NOTE: ret.info is set in the fixup phase.
771771
ret.arg_names = data['arg_names']
772772
ret.arg_kinds = [ArgKind(x) for x in data['arg_kinds']]
773+
ret.arguments = []
774+
for argname, argkind in zip(ret.arg_names, ret.arg_kinds):
775+
ret.arguments += [Argument(Var(argname or ""), None, None, argkind)]
773776
# Leave these uninitialized so that future uses will trigger an error
774-
del ret.arguments
775777
del ret.max_pos
776778
del ret.min_args
777779
return ret

mypy/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ def __init__(self,
12361236
self.def_extras = {
12371237
'first_arg': (
12381238
definition.arguments[0].variable.name
1239-
if (getattr(definition, 'arguments', None)
1239+
if (definition.arguments
12401240
and definition.arg_names
12411241
and definition.info
12421242
and not definition.is_static)

0 commit comments

Comments
 (0)