-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logic to detect illegal use of the symbol
Any
. This addresses #…
- Loading branch information
Showing
5 changed files
with
77 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This sample tests certain uses of Any that should be flagged as illegal. | ||
|
||
from typing import Any, cast | ||
import typing | ||
|
||
|
||
isinstance(0, Any) | ||
isinstance(0, typing.Any) | ||
|
||
v1 = cast(Any, 0) | ||
v2 = cast(typing.Any, 0) | ||
|
||
|
||
class A(Any): | ||
... | ||
|
||
|
||
class B(typing.Any): | ||
... | ||
|
||
|
||
# This should generate an error because Any is not callable. | ||
Any() | ||
|
||
# This should generate an error because Any is not callable. | ||
typing.Any() | ||
|
||
|
||
def func1() -> int: | ||
# This should generate an error because Any cannot be used as a value. | ||
return Any | ||
|
||
|
||
def func2() -> int: | ||
# This should generate an error because Any cannot be used as a value. | ||
return typing.Any |
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