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
deff(): ... # just to have something returning Anydeflookup_field(name, obj):
try:
passexcept:
attr=f()
else:
attr=None
with --check-untyped-defs --strict-optional gives
Traceback (most recent call last):
File "/usr/lib/python-exec/python3.4/mypy", line 6, in <module>
main(__file__)
File "/usr/lib64/python3.4/site-packages/mypy/main.py", line 40, in main
res = type_check_only(sources, bin_dir, options)
File "/usr/lib64/python3.4/site-packages/mypy/main.py", line 81, in type_check_only
options=options)
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 178, in build
dispatch(sources, manager)
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 1325, in dispatch
process_graph(graph, manager)
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 1468, in process_graph
process_stale_scc(graph, scc)
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 1545, in process_stale_scc
graph[id].type_check()
File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 1303, in type_check
manager.type_checker.visit_file(self.tree, self.xpath)
File "/usr/lib64/python3.4/site-packages/mypy/checker.py", line 152, in visit_file
self.accept(d)
File "/usr/lib64/python3.4/site-packages/mypy/checker.py", line 201, in accept
typ = node.accept(self)
File "/usr/lib64/python3.4/site-packages/mypy/nodes.py", line 476, in accept
return visitor.visit_func_def(self)
File "/usr/lib64/python3.4/site-packages/mypy/checker.py", line 399, in visit_func_def
self.check_func_item(defn, name=defn.name())
File "/usr/lib64/python3.4/site-packages/mypy/checker.py", line 466, in check_func_item
self.leave_partial_types()
File "/usr/lib64/python3.4/site-packages/mypy/checker.py", line 2191, in leave_partial_types
if experiments.STRICT_OPTIONAL and cast(PartialType, var.type).type is None:
AttributeError: 'AnyType' object has no attribute 'type'
*** INTERNAL ERROR ***
/tmp/asd8.py:3: 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 text was updated successfully, but these errors were encountered:
tharvik
changed the title
AttributeError: 'AnyType' object has no attribute 'type' in try/except and
AttributeError: 'AnyType' object has no attribute 'type' in try/except/else
Jul 27, 2016
Some --strict-optional code previously assumed that the partial_types list could only contain PartialTypes. In some cases, it appears AnyType can also be part of that list. It's not entirely clear to me what causes this, but it looks like the correct solution is to be robust to the presence of other types in that list.
Fixes#1948.
with
--check-untyped-defs --strict-optional
givesThis is a small repro based on django:django/contrib/admin/utils.py:276.
The text was updated successfully, but these errors were encountered: