You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While writing an iterable file-like class class MyFileLike(object) I was having trouble getting the Iterable protocol to be implicitly recognized. So I decided to add an explicit Iterable parent:
Traceback (most recent call last):
File "/home/machinalis/.virtualenvs/mypy-django/bin/mypy", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/home/machinalis/oss/mypy/scripts/mypy", line 6, in <module>
main(__file__)
File "/home/machinalis/oss/mypy/mypy/main.py", line 38, in main
res = type_check_only(sources, bin_dir, options)
File "/home/machinalis/oss/mypy/mypy/main.py", line 79, in type_check_only
options=options)
File "/home/machinalis/oss/mypy/mypy/build.py", line 180, in build
dispatch(sources, manager)
File "/home/machinalis/oss/mypy/mypy/build.py", line 1335, in dispatch
process_graph(graph, manager)
File "/home/machinalis/oss/mypy/mypy/build.py", line 1478, in process_graph
process_stale_scc(graph, scc)
File "/home/machinalis/oss/mypy/mypy/build.py", line 1551, in process_stale_scc
graph[id].semantic_analysis()
File "/home/machinalis/oss/mypy/mypy/build.py", line 1300, in semantic_analysis
self.manager.semantic_analyzer.visit_file(self.tree, self.xpath)
File "/home/machinalis/oss/mypy/mypy/semanal.py", line 244, in visit_file
self.accept(d)
File "/home/machinalis/oss/mypy/mypy/semanal.py", line 2462, in accept
node.accept(self)
File "/home/machinalis/oss/mypy/mypy/nodes.py", line 664, in accept
return visitor.visit_class_def(self)
File "/home/machinalis/oss/mypy/mypy/semanal.py", line 572, in visit_class_def
defn.defs.accept(self)
File "/home/machinalis/oss/mypy/mypy/nodes.py", line 727, in accept
return visitor.visit_block(self)
File "/home/machinalis/oss/mypy/mypy/semanal.py", line 1028, in visit_block
self.accept(s)
File "/home/machinalis/oss/mypy/mypy/semanal.py", line 2462, in accept
node.accept(self)
File "/home/machinalis/oss/mypy/mypy/nodes.py", line 765, in accept
return visitor.visit_assignment_stmt(self)
File "/home/machinalis/oss/mypy/mypy/semanal.py", line 1060, in visit_assignment_stmt
s.rvalue.accept(self)
File "/home/machinalis/oss/mypy/mypy/nodes.py", line 1116, in accept
return visitor.visit_name_expr(self)
File "/home/machinalis/oss/mypy/mypy/semanal.py", line 1906, in visit_name_expr
n = self.lookup(expr.name, expr)
File "/home/machinalis/oss/mypy/mypy/semanal.py", line 2250, in lookup
return self.type[name]
File "/home/machinalis/oss/mypy/mypy/nodes.py", line 1864, in __getitem__
raise KeyError(name)
KeyError: 'readlines'
*** INTERNAL ERROR ***
myiter.py:7: error: Internal error -- please report a bug at https://github.com/python/mypy/issues
NOTE: you can use "mypy --pdb ..." to drop into the debugger when this happens.
The crash goes away if I remove the object reference and only inherit from Iterable[str].
The text was updated successfully, but these errors were encountered:
Yeah, this is an easy repro. There are too many similar crashes where apparently the mro is used after an error message about it has been produced. :-( In this case, the code first produced the error
error: Cannot determine consistent method resolution order (MRO) for "MyFileLike"
Errors are buffered so you don't see them when there's a crash. (Hmm... Maybe we could fix that!)
While writing an iterable file-like class
class MyFileLike(object)
I was having trouble getting theIterable
protocol to be implicitly recognized. So I decided to add an explicitIterable
parent:That snippet crashes mypy:
The crash goes away if I remove the
object
reference and only inherit fromIterable[str]
.The text was updated successfully, but these errors were encountered: