mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-27 11:18:42 +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
|
||||
// unless they are objects that support the __nonzero__ or __len__
|
||||
// unless they are objects that support the __bool__ or __len__
|
||||
// methods.
|
||||
export function canBeFalsy(type: Type): boolean {
|
||||
if (type.category === TypeCategory.None) {
|
||||
@ -481,8 +481,8 @@ export function canBeFalsy(type: Type): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
const nonZeroMethod = lookUpObjectMember(type, '__nonzero__');
|
||||
if (nonZeroMethod) {
|
||||
const boolethod = lookUpObjectMember(type, '__bool__');
|
||||
if (boolethod) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user