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
I ran it through Mypy and got an error message saying to run it with --show-traceback. I did that and got the following output:
fraction_test.py:5: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.570-dev-c25dd085a78047a9d5e0909261e8261506505d35
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/mypy", line 11, in <module>
load_entry_point('mypy===0.570-dev-c25dd085a78047a9d5e0909261e8261506505d35', 'console_scripts', 'mypy')()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
main(None)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/main.py", line 80, in main
type_check_only(sources, bin_dir, options, flush_errors)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/main.py", line 129, in type_check_only
flush_errors=flush_errors)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 180, in build
result = _build(sources, options, alt_lib_path, bin_dir, saved_cache, flush_errors)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 266, in _build
graph = dispatch(sources, manager)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 2112, in dispatch
process_graph(graph, manager)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 2413, in process_graph
process_stale_scc(graph, scc, manager)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 2597, in process_stale_scc
graph[id].type_check_first_pass()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 1969, in type_check_first_pass
self.type_checker().check_first_pass()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 229, in check_first_pass
self.accept(d)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 324, in accept
stmt.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/nodes.py", line 704, in accept
return visitor.visit_class_def(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 1252, in visit_class_def
self.accept(defn.defs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 324, in accept
stmt.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/nodes.py", line 766, in accept
return visitor.visit_block(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 1395, in visit_block
self.accept(s)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 324, in accept
stmt.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/nodes.py", line 501, in accept
return visitor.visit_func_def(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 576, in visit_func_def
self.check_func_item(defn, name=defn.name())
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 641, in check_func_item
self.check_func_def(defn, typ, name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 691, in check_func_def
self.check_reverse_op_method(item, typ, name, defn)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 926, in check_reverse_op_method
defn)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/checker.py", line 996, in check_overlapping_op_methods
forward_base.type.name(), forward_name, context)
AttributeError: 'UnionType' object has no attribute 'type'
fraction_test.py:5: : note: use --pdb to drop into pdb
This seems to have something to do with overloading the swapped binary arithmetic operations. If I change the method name to __rsub__ or __rmul__, I get a similar error, but with __add__ or __sub__ or nonsense names like __foo__, I don't get any errors.
If I change the type hint for other to simply float or Fraction, I get no errors.
If I change the return type hint to str or List (and make the method return something that matches that type), I get similar errors. But if I remove the return type hint, I get no errors.
If I move the method outside of the class (making it a regular function), I get a similar error. Such a thing may be silly, but I don't see why it should be invalid.
The text was updated successfully, but these errors were encountered:
I have a file with the following code:
I ran it through Mypy and got an error message saying to run it with
--show-traceback
. I did that and got the following output:This seems to have something to do with overloading the swapped binary arithmetic operations. If I change the method name to
__rsub__
or__rmul__
, I get a similar error, but with__add__
or__sub__
or nonsense names like__foo__
, I don't get any errors.If I change the type hint for
other
to simplyfloat
orFraction
, I get no errors.If I change the return type hint to
str
orList
(and make the method return something that matches that type), I get similar errors. But if I remove the return type hint, I get no errors.If I move the method outside of the class (making it a regular function), I get a similar error. Such a thing may be silly, but I don't see why it should be invalid.
The text was updated successfully, but these errors were encountered: