mirror of
https://github.com/microsoft/pyright.git
synced 2024-11-13 09:34:44 +03:00
Fixed bug in callable
type narrowing logic where the union of the type includes None
.
This commit is contained in:
parent
8c01e0d652
commit
9a991dc8d3
@ -12660,6 +12660,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
||||
return isPositiveTest ? subtype : undefined;
|
||||
}
|
||||
|
||||
case TypeCategory.None:
|
||||
case TypeCategory.Module: {
|
||||
return isPositiveTest ? undefined : subtype;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This sample tests the type engine's narrowing logic for
|
||||
# callable expressions.
|
||||
|
||||
from typing import Callable, Type, Union
|
||||
from typing import Callable, Optional, Type, Union
|
||||
|
||||
|
||||
class CallableObj:
|
||||
@ -29,3 +29,8 @@ if callable(q):
|
||||
if not callable(q):
|
||||
a = q + 3
|
||||
|
||||
|
||||
def g(a: Optional[Callable[[int], int]]):
|
||||
if callable(a):
|
||||
a(3)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user