-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented type analysis support for comparison chaining.
- Loading branch information
1 parent
a109484
commit 57ca2da
Showing
3 changed files
with
43 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This sample tests the type checker's handling of chained | ||
# comparison operators. | ||
|
||
from datetime import datetime | ||
|
||
def requires_bool(val: bool): | ||
pass | ||
|
||
date1 = datetime.now() | ||
date2 = datetime.now() | ||
date3 = datetime.now() | ||
|
||
foo1 = date1 < date2 <= date3 | ||
requires_bool(foo1) | ||
|
||
int1 = 3 | ||
foo2 = 2 < int1 < 5 | ||
requires_bool(foo2) | ||
|
||
# This should generate an error because | ||
# int and datetime cannot be compared. | ||
foo3 = date1 < date2 < 3 | ||
|
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