-
-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,49 @@ | ||
[case test_type_annotations] | ||
[case test_type_annotations_pep526] | ||
# cmd: mypy a.py | ||
[file a.py] | ||
import attr | ||
|
||
@attr.s | ||
class C(object): | ||
a : int = attr.ib() | ||
b = attr.ib(type=int) | ||
|
||
c = C() | ||
reveal_type(c.a) | ||
reveal_type(c.b) | ||
reveal_type(C.a) | ||
reveal_type(C.b) | ||
[out] | ||
a.py:8: error: Revealed type is 'builtins.int' | ||
a.py:9: error: Revealed type is 'builtins.int' | ||
a.py:10: error: Revealed type is 'builtins.int' | ||
a.py:11: error: Revealed type is 'builtins.int' | ||
a.py:12: error: Revealed type is 'builtins.int' | ||
|
||
|
||
[case test_type_annotations_arg] | ||
# cmd: mypy a.py | ||
[file a.py] | ||
import attr | ||
|
||
@attr.s | ||
class C(object): | ||
a = attr.ib(type=int) | ||
|
||
c = C() | ||
reveal_type(c.a) | ||
reveal_type(C.a) | ||
[out] | ||
a.py:8: error: Revealed type is 'builtins.int*' | ||
a.py:9: error: Revealed type is 'builtins.int*' | ||
|
||
|
||
[case test_type_annotations_missing] | ||
# cmd: mypy a.py | ||
[file a.py] | ||
import attr | ||
|
||
@attr.s | ||
class C(object): | ||
a = attr.ib() | ||
|
||
c = C() | ||
reveal_type(c.a) | ||
reveal_type(C.a) | ||
[out] | ||
a.py:8: error: Revealed type is 'Any' | ||
a.py:9: error: Revealed type is 'Any' |