Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support additional unpacking generalisations (PEP 448) #704

Closed
spkersten opened this issue Jun 1, 2015 · 2 comments · Fixed by #1960
Closed

Support additional unpacking generalisations (PEP 448) #704

spkersten opened this issue Jun 1, 2015 · 2 comments · Fixed by #1960
Assignees
Labels

Comments

@spkersten
Copy link
Contributor

No description provided.

@JukkaL JukkaL added the feature label Jun 3, 2015
@JukkaL
Copy link
Collaborator

JukkaL commented Jun 3, 2015

@mbdevpl
Copy link

mbdevpl commented Jun 22, 2016

I just would like to add that although the new parser (mentioned in #1353) parses below:

my_dict = {'b': 2, 'c': 3}
my_new_dict = {'a': 1, **my_dict}

mypy ends up in a bad place:

$ python3.5 -m mypy --fast-parser mypy_pep0448.py
Traceback (most recent call last):
  File "/home/mb/.local/lib/python3.5/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/mb/.local/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/__main__.py", line 5, in <module>
    main(None)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/main.py", line 54, in main
    res = type_check_only(sources, bin_dir, options)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/main.py", line 102, in type_check_only
    python_path=options.python_path)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/build.py", line 211, in build
    dispatch(sources, manager)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/build.py", line 1334, in dispatch
    graph = load_graph(sources, manager)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/build.py", line 1349, in load_graph
    st = State(id=bs.module, path=bs.path, source=bs.text, manager=manager)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/build.py", line 1121, in __init__
    self.parse_file()
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/build.py", line 1232, in parse_file
    self.tree = manager.parse_file(self.id, self.xpath, source)
  File "/home/mb/.local/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/build.py", line 1186, in wrap_context
    yield
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/build.py", line 1232, in parse_file
    self.tree = manager.parse_file(self.id, self.xpath, source)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/build.py", line 452, in parse_file
    fast_parser=FAST_PARSER in self.flags)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/parse.py", line 88, in parse
    custom_typing_module=custom_typing_module)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/fastparse.py", line 66, in parse
    ).visit(ast)
  File "/home/mb/.local/lib/python3.5/site-packages/typed_ast/ast35.py", line 252, in visit
    return visitor(node)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/fastparse.py", line 228, in visit_Module
    body = self.fix_function_overloads(self.visit_list(mod.body))
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/fastparse.py", line 129, in visit_list
    return [self.visit(e) for e in l]
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/fastparse.py", line 129, in <listcomp>
    return [self.visit(e) for e in l]
  File "/home/mb/.local/lib/python3.5/site-packages/typed_ast/ast35.py", line 252, in visit
    return visitor(node)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/fastparse.py", line 97, in wrapper
    node = f(self, ast)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/fastparse.py", line 387, in visit_Assign
    self.visit(n.value),
  File "/home/mb/.local/lib/python3.5/site-packages/typed_ast/ast35.py", line 252, in visit
    return visitor(node)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/fastparse.py", line 97, in wrapper
    node = f(self, ast)
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/fastparse.py", line 574, in visit_Dict
    return DictExpr(list(zip(self.visit_list(n.keys), self.visit_list(n.values))))
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/nodes.py", line 1445, in __init__
    for x in items):
  File "/home/mb/.local/lib/python3.5/site-packages/mypy/nodes.py", line 1445, in <genexpr>
    for x in items):
AttributeError: 'NoneType' object has no attribute 'literal'

for reference, using current parser:

$ python3.5 -m mypy mypy_pep0448.py
mypy_pep0448.py:2: error: Parse error before **

also for reference: Ubuntu 14.04 x64, Python 3.5.1, mypy 0.4.2, typed-ast 0.5.2

@gvanrossum gvanrossum changed the title Support additional unpacking generalisations (PEP 0448) Support additional unpacking generalisations (PEP 448) Jul 27, 2016
@gvanrossum gvanrossum added this to the 0.4.x milestone Jul 27, 2016
@gvanrossum gvanrossum self-assigned this Jul 27, 2016
gvanrossum added a commit that referenced this issue Jul 29, 2016
This fixes #1722 and addresses most of #704 (but doesn't close it, because of {**x}).
gvanrossum added a commit that referenced this issue Jul 29, 2016
Together with PR #1953 (incorporated herein) this fixes #704.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants