TEST: Add xfailing test for [func-returns-value]#17834
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 |
brianschubert
left a comment
There was a problem hiding this comment.
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>
brianschubert
left a comment
There was a problem hiding this comment.
LGTM
Both tests pass when I force all function calls to always return None.
|
Superseded by #18015 |
Add an xfailing test that reproduces #14179.