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
{{ message }}
Repository navigation
Incorrent "Missing return statement" in presence of bad combination of decorated function call, definition order and NoReturn #8129
I tested this both with mypy 0.750 and one from the current master branch (526a218), running on CPython 3.7.5. The command line and the output:
% python -m mypy repro.py
repro.py:8: error: Missing return statement
Found 1 error in 1 file (checked 1 source file)
I'd expect no errors here. After some digging in mypy source code I believe use_decorated_before_defined can't be fully processed when it's type-checked (at least the first time it's entered) because of a) the call to decorated being looked at before decorated is defined and b) decorated being decorated (pardon my repetition) with a result of another function call which I suspect creates a difficult environment for mypy to deduce things and it defers further processing of use_decorated_before_defined (or at least part of it).
Then, when the call to no_return is encountered its type is detected as Any because of the processing being deferred per above, hence the error.
I left two similar variants of the function (use_decorated_after_defined and use_wrapped_before_defined) to help narrow things down as those don't trigger the error.
Shouldn't the title of this issue be made more generic, since issue #8401 is a duplicate of this, but does match the title?
I have an issue similar to #8401 (NoReturn being confused by code being run before definition) but am not sure whether to post here or create separate issue.
Activity
msullivan commentedon Dec 12, 2019
Yeah, this seems legit and somewhat hairy. I suspect you are right and the issue is that the node is being deferred.
I think that this can be fixed by adding a check for if the node is deferred, though that feels ugly.
LEdoian commentedon Aug 12, 2022
Shouldn't the title of this issue be made more generic, since issue #8401 is a duplicate of this, but does match the title?
I have an issue similar to #8401 (
NoReturnbeing confused by code being run before definition) but am not sure whether to post here or create separate issue.Fix spurious unreachable and disallow-any errors from deferred passes
Fix spurious unreachable and disallow-any errors from deferred passes
Fix spurious unreachable and disallow-any errors from deferred passes (…