KEMBAR78
Internal error when using reveal_locals() inside class that contains an inner class · Issue #5915 · python/mypy · GitHub
Skip to content

Internal error when using reveal_locals() inside class that contains an inner class #5915

@mthuurne

Description

@mthuurne

While trying to dig deeper on #5914, I ran into an internal error in mypy.

I ran mypy on this code, without any arguments other than the file name:

class Outer:
    class Inner:
        pass
    reveal_locals()

This is the traceback: (paths shortened)

Traceback (most recent call last):
  File ".../bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File ".../lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File ".../lib/python3.6/site-packages/mypy/main.py", line 92, in main
    res = build.build(sources, options, None, flush_errors, fscache)
  File ".../lib/python3.6/site-packages/mypy/build.py", line 155, in build
    result = _build(sources, options, alt_lib_path, flush_errors, fscache)
  File ".../lib/python3.6/site-packages/mypy/build.py", line 204, in _build
    graph = dispatch(sources, manager)
  File ".../lib/python3.6/site-packages/mypy/build.py", line 2172, in dispatch
    process_graph(graph, manager)
  File ".../lib/python3.6/site-packages/mypy/build.py", line 2469, in process_graph
    process_stale_scc(graph, scc, manager)
  File ".../lib/python3.6/site-packages/mypy/build.py", line 2592, in process_stale_scc
    graph[id].type_check_first_pass()
  File ".../lib/python3.6/site-packages/mypy/build.py", line 1730, in type_check_first_pass
    self.type_checker().check_first_pass()
  File ".../lib/python3.6/site-packages/mypy/checker.py", line 282, in check_first_pass
    self.accept(d)
  File ".../lib/python3.6/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File ".../lib/python3.6/site-packages/mypy/nodes.py", line 845, in accept
    return visitor.visit_class_def(self)
  File ".../lib/python3.6/site-packages/mypy/checker.py", line 1536, in visit_class_def
    self.accept(defn.defs)
  File ".../lib/python3.6/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File ".../lib/python3.6/site-packages/mypy/nodes.py", line 910, in accept
    return visitor.visit_block(self)
  File ".../lib/python3.6/site-packages/mypy/checker.py", line 1688, in visit_block
    self.accept(s)
  File ".../lib/python3.6/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File ".../lib/python3.6/site-packages/mypy/nodes.py", line 925, in accept
    return visitor.visit_expression_stmt(self)
  File ".../lib/python3.6/site-packages/mypy/checker.py", line 2602, in visit_expression_stmt
    self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
  File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 3003, in accept
    typ = self.visit_call_expr(node, allow_none_return=True)
  File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 228, in visit_call_expr
    return self.accept(e.analyzed, self.type_context[-1])
  File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 3007, in accept
    typ = node.accept(self)
  File ".../lib/python3.6/site-packages/mypy/nodes.py", line 1674, in accept
    return visitor.visit_reveal_expr(self)
  File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 2362, in visit_reveal_expr
    } if expr.local_nodes is not None else {}
  File ".../lib/python3.6/site-packages/mypy/checkexpr.py", line 2361, in <dictcomp>
    var_node.name(): var_node.type for var_node in expr.local_nodes
AttributeError: 'TypeInfo' object has no attribute 'type'

I'm using mypy 0.641 on Python 3.6.5.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions