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
Running mypy on this with the --warn-return-any option produces the error "Returning Any from function declared to return "Type[int]"", even though the assert issubclass should convince mypy that x is of type Type[int] and not an Any.
Your Environment
Mypy version used: 0.902
Mypy command-line flags: --warn-return-any
Mypy configuration options from mypy.ini (and other config files): none
Python version used: Python 3.9.5
Operating system and version: macOS 11.3.1
The text was updated successfully, but these errors were encountered:
Just in case it's a useful test-case, I have a slight variation on this error, where it's clear from looking that we can deduce the narrowed return type in all conditional paths but where mypy complains that it thinks we could potentially be dealing with an 'Any' type -
deff(something: bool) ->dict:
my_dict=Noneifsomething:
exec('d = {}', globals(), locals())
my_dict=locals()['d']
assertisinstance(my_dict, dict)
# ... No good if we use this assert.else:
my_dict= {}
# assert isinstance(my_dict, dict)# ... but all good if we use this assertreturnmy_dict
Consider the following (contrived) code:
Running mypy on this with the
--warn-return-any
option produces the error "Returning Any from function declared to return "Type[int]"
", even though theassert issubclass
should convince mypy thatx
is of typeType[int]
and not anAny
.Your Environment
--warn-return-any
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: