Skip to content

TypedDict RecursionError #5357

Description

@dmfigol
  • Are you reporting a bug, or opening a feature request?
    Bug
  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
from typing import Dict, Any, Optional
from mypy_extensions import TypedDict
VarsDict = Dict[str, Any]
HostsDict = Dict[str, Optional[VarsDict]]
GroupDataDict = TypedDict(
"GroupDataDict", {"children": "GroupsDict",
"vars": VarsDict,
"hosts": HostsDict}, total=False
)
GroupsDict = Dict[str, GroupDataDict]

trying to describe the following data (YAML):

all:
children:
servers:
children:
webservers:
hosts:
foo.example.com:
bar.example.com:
dbservers:
hosts:
one.example.com:
two.example.com:
my_var: from_hostfilethree.example.com:
ansible_port: 5555ansible_host: 192.0.2.50vars:
some_server: foo.southeast.example.comhalon_system_timeout: 30self_destruct_countdown: 60escape_pods: 2frontend:
hosts:
foo.example.com:
  • What is the actual behavior/output?
    Crash
  • What is the behavior/output you expect?
    No crash
  • What are the versions of mypy and Python you are using?
    0.610 + Python 3.7 / 3.6.6
  • Do you see the same issue after installing mypy from Git master?
    Haven't checked
  • What are the mypy flags you are using? (For example --strict-optional)
[mypy]
python_version = 3.6
check_untyped_defs = True
disallow_any_generics = True
disallow_untyped_calls = True
ignore_errors = False
ignore_missing_imports = True
strict_optional = True
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True
  • If mypy crashed with a traceback, please paste
    the full traceback below.
...
for l in it:
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1933, in <genexpr>
return self.strategy(t.accept(self) for t in types)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1475, in accept
return visitor.visit_forwardref_type(self)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1921, in visit_forwardref_type
return t.resolved.accept(self)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 512, in accept
return visitor.visit_instance(self)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1895, in visit_instance
return self.query_types(t.args)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1933, in query_types
return self.strategy(t.accept(self) for t in types)
File "/usr/local/lib/python3.7/site-packages/mypy/typeanal.py", line 990, in combine_lists_strategy
for l in it:
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1933, in <genexpr>
return self.strategy(t.accept(self) for t in types)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1103, in accept
return visitor.visit_typeddict_type(self)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1905, in visit_typeddict_type
return self.query_types(t.items.values())
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1933, in query_types
return self.strategy(t.accept(self) for t in types)
File "/usr/local/lib/python3.7/site-packages/mypy/typeanal.py", line 990, in combine_lists_strategy
for l in it:
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1933, in <genexpr>
return self.strategy(t.accept(self) for t in types)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1475, in accept
return visitor.visit_forwardref_type(self)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1921, in visit_forwardref_type
return t.resolved.accept(self)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 512, in accept
return visitor.visit_instance(self)
File "/usr/local/lib/python3.7/site-packages/mypy/types.py", line 1895, in visit_instance
return self.query_types(t.args)
RecursionError: maximum recursion depth exceeded

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions