Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d309e44

Browse files
authored
not x is bool for any x (#32)
1 parent 6cc280d commit d309e44

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

autotyping/autotyping.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ def type_of_expression(expr: libcst.BaseExpression) -> Optional[Type[object]]:
540540
return None
541541
elif isinstance(expr, libcst.Name) and expr.value in ("True", "False"):
542542
return bool
543+
elif isinstance(expr, libcst.UnaryOperation) and isinstance(
544+
expr.operator, libcst.Not
545+
):
546+
return bool
543547
elif (
544548
isinstance(expr, libcst.Call)
545549
and isinstance(expr.func, libcst.Attribute)

tests/test_codemod.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def foo():
4949
def bar():
5050
return 1
5151
52+
def return_not(x):
53+
return not x
54+
5255
def formatter(x):
5356
return "{}".format(x)
5457
@@ -68,6 +71,9 @@ def foo():
6871
def bar() -> int:
6972
return 1
7073
74+
def return_not(x) -> bool:
75+
return not x
76+
7177
def formatter(x) -> str:
7278
return "{}".format(x)
7379

0 commit comments

Comments
 (0)