-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Annotate functions in tests #4434
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1403,7 +1403,7 @@ b[{}] = 1 | |
|
||
[case testInferDictInitializedToEmptyAndUpdatedFromMethod] | ||
map = {} | ||
def add(): | ||
def add() -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unclear if the annotation was omitted intentionally. I'd suggest creating two variants of the test case. |
||
map[1] = 2 | ||
[builtins fixtures/dict.pyi] | ||
[out] | ||
|
@@ -1959,7 +1959,7 @@ class C: | |
|
||
if bool(): | ||
f() | ||
1 + '' # E: Unsupported left operand type for + ("int") | ||
1 + '' # E: Unsupported operand types for + ("int" and "str") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer changing the test case so that we don't depend on |
||
[builtins fixtures/list.pyi] | ||
[out] | ||
|
||
|
@@ -1976,7 +1976,7 @@ class C: | |
|
||
if bool(): | ||
f() | ||
1 + '' # E: Unsupported left operand type for + ("int") | ||
1 + '' # E: Unsupported operand types for + ("int" and "str") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above, I'd prefer using |
||
[builtins fixtures/list.pyi] | ||
[out] | ||
|
||
|
@@ -1992,6 +1992,6 @@ class C: | |
|
||
if bool(): | ||
f([]) | ||
1 + '' # E: Unsupported left operand type for + ("int") | ||
1 + '' # E: Unsupported operand types for + ("int" and "str") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above. |
||
[builtins fixtures/list.pyi] | ||
[out] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1312,7 +1312,7 @@ class A: | |
def f(self) -> str: return 'foo' | ||
class B(A): | ||
def f(self) -> str: return self.x | ||
def initialize(self): self.x = 'bar' | ||
def initialize(self) -> None: self.x = 'bar' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not having a return type may have well been intentional. I'd prefer either keeping the original test case or adding another variant with a return type annotation. |
||
[out] | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,7 +353,7 @@ a @= 1 # E: Argument 1 to "__imatmul__" of "A" has incompatible type "int"; exp | |
|
||
[case testInplaceSetitem] | ||
class A(object): | ||
def __init__(self): | ||
def __init__(self) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
self.a = 0 | ||
|
||
def __iadd__(self, a): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,8 @@ class list(Generic[T]): | |
|
||
class tuple(Generic[T]): pass | ||
class function: pass | ||
class int: pass | ||
class int: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed above, I wouldn't change the fixture. |
||
def __add__(self, other: 'int') -> 'int': pass | ||
class float: pass | ||
class str: pass | ||
class bool(int): pass | ||
|
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.
I think that omitting the return type was intentional here. It would be okay to have two variants of this method, one with an annotation for
__init__
and another without.