mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-27 19:28:46 +03:00
Switched from __nonzero__ to __bool__ when checking for falsiness. The former was deprecated in python 3.0.
This commit is contained in:
parent
18300ba5b6
commit
a83c46d229
@ -460,7 +460,7 @@ export function canBeTruthy(type: Type): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// None is always falsy. All other types are generally truthy
|
// None is always falsy. All other types are generally truthy
|
||||||
// unless they are objects that support the __nonzero__ or __len__
|
// unless they are objects that support the __bool__ or __len__
|
||||||
// methods.
|
// methods.
|
||||||
export function canBeFalsy(type: Type): boolean {
|
export function canBeFalsy(type: Type): boolean {
|
||||||
if (type.category === TypeCategory.None) {
|
if (type.category === TypeCategory.None) {
|
||||||
@ -481,8 +481,8 @@ export function canBeFalsy(type: Type): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nonZeroMethod = lookUpObjectMember(type, '__nonzero__');
|
const boolethod = lookUpObjectMember(type, '__bool__');
|
||||||
if (nonZeroMethod) {
|
if (boolethod) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user