-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
TEST: Add xfailing test for [func-returns-value] #17834
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
Conversation
Is there a canonical way to point back to the github issue from the test code, so that if the test passes at some point, it is easy to also close the issue? |
I don't know about a canonical way, but any comment that points to the issue number / URL would probably be fine. |
I added the URL as a comment. |
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
I think this test would be better suited for
|
This issue appear to affect any decorated function, so there may be value in including a test using an arbitrary dummy decorator, and with multiple levels of decoration. For your consideration, please feel free to adapt as you see fit: # test-data/unit/check-expressions.test
[case testNoneReturnDecorated]
from typing import Any, Callable, TypeVar
F = TypeVar('F', bound=Callable[..., Any])
def deco(f: F) -> F:
pass
@deco
@deco
def f() -> None:
pass
class A:
@staticmethod
def s() -> None:
pass
if int():
x = f() # E: "f" does not return a value (it only ever returns None)
if int():
x = A.s() # E: "s" of "A" does not return a value (it only ever returns None)
if int():
x = A().s() # E: "s" of "A" does not return a value (it only ever returns None)
[builtins fixtures/staticmethod.pyi] |
Moved and renamed the test.
Good catch! I expanded the test based on your example. EDIT: Also added an xfailing test for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
The __call__
case is interesting. There are some other tests that cover opaque callables in other kinds of expressions, like f = A(); y = f()
. It seems that the relevant bit here is having the callee be a CallExpr
A few nits on the error messages:
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Both tests pass when I force all function calls to always return None
.
Superseded by #18015 |
Add an xfailing test that reproduces #14179.