Skip to content

Crash when __lt__ has a second argument #5347

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

Closed
srittau opened this issue Jul 12, 2018 · 1 comment
Closed

Crash when __lt__ has a second argument #5347

srittau opened this issue Jul 12, 2018 · 1 comment

Comments

@srittau
Copy link
Contributor

srittau commented Jul 12, 2018

Please consider the following stub file:

class Foo:
    def __lt__(self, other: object, context: str = ...) -> bool: ...

Checking it with either mypy 0.610 or current HEAD (0.620+dev-b07f8f5bdaeb25fc4111c2a01276635123f1a293) with Python 3.7.0 (and other versions) results in the following crash:

srittau@moby:~$ mypy --show-traceback test.pyi 
test.pyi:2: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.620+dev-b07f8f5bdaeb25fc4111c2a01276635123f1a293
Traceback (most recent call last):
  File "/home/srittau/.local/bin/mypy", line 11, in <module>
    load_entry_point('mypy==0.620+dev.b07f8f5bdaeb25fc4111c2a01276635123f1a293', 'console_scripts', 'mypy')()
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/main.py", line 91, in main
    res = type_check_only(sources, bin_dir, options, flush_errors, fscache)  # noqa
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/main.py", line 148, in type_check_only
    fscache=fscache)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 177, in build
    flush_errors, fscache)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 350, in _build
    graph = dispatch(sources, manager)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 2560, in dispatch
    process_graph(graph, manager)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 2853, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 2976, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/build.py", line 2151, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 253, in check_first_pass
    self.accept(d)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 352, in accept
    stmt.accept(self)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/nodes.py", line 808, in accept
    return visitor.visit_class_def(self)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 1368, in visit_class_def
    self.accept(defn.defs)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 352, in accept
    stmt.accept(self)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/nodes.py", line 873, in accept
    return visitor.visit_block(self)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 1514, in visit_block
    self.accept(s)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 352, in accept
    stmt.accept(self)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/nodes.py", line 591, in accept
    return visitor.visit_func_def(self)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 663, in visit_func_def
    self._visit_func_def(defn)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 667, in _visit_func_def
    self.check_func_item(defn, name=defn.name())
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 729, in check_func_item
    self.check_func_def(defn, typ, name)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 779, in check_func_def
    self.check_reverse_op_method(item, typ, name, defn)
  File "/home/srittau/.local/lib/python3.7/site-packages/mypy/checker.py", line 1006, in check_reverse_op_method
    assert len(reverse_type.arg_types) == 2
AssertionError: 
test.pyi:2: : note: use --pdb to drop into pdb
@emmatyping
Copy link
Member

Closing as a duplicate of #5337. The current check is too strict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants