Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add test for basic functionality
  • Loading branch information
ilinum committed Jun 19, 2017
commit 52b9206294769d65c0b3b524c0d5429c23911ba1
19 changes: 19 additions & 0 deletions test-data/unit/check-flags.test
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,25 @@ x, y = 1, 2 # type: Unchecked, Unchecked
main:4: error: Type of variable becomes "Any" due to an unfollowed import
main:6: error: A type on this line becomes "Any" due to an unfollowed import

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to have some tests for the basic functionality. These tests do a good job of exercising the more interesting edge cases, but it's worth testing putting an Any type in a variety of expressions to make sure it's caught/the behavior is what we expect.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Let me know if you have any other test ideas.

[case testDisallowAnyExprSimple]
# flags: --disallow-any=expr
from typing import Any
def f(s):
yield s

x = f(0) # E: Expression has type "Any"
for x in f(0): # E: Expression has type "Any"
g(x) # E: Expression has type "Any"

def g(x) -> Any:
yield x # E: Expression has type "Any"

l = [1, 2, 3]
l[f(0)] # E: Expression has type "Any"
f(l)
f(f(0)) # E: Expression has type "Any"
[builtins fixtures/list.pyi]

[case testDisallowAnyExprUnannotatedFunction]
# flags: --disallow-any=expr
def g(s):
Expand Down