mirror of
https://github.com/microsoft/pyright.git
synced 2024-11-13 09:34:44 +03:00
Added checks in type validator for metaclasses.
This commit is contained in:
parent
7979c5d177
commit
9565833cc8
@ -893,6 +893,43 @@ export class PackageTypeVerifier {
|
||||
}
|
||||
});
|
||||
|
||||
// Add information for the metaclass.
|
||||
if (type.details.effectiveMetaclass) {
|
||||
if (!isClass(type.details.effectiveMetaclass)) {
|
||||
diag.addMessage(`Type for metaclass is unknown`);
|
||||
isKnown = false;
|
||||
} else if (!ClassType.isBuiltIn(type.details.effectiveMetaclass)) {
|
||||
const metaclassInfo = this._validateClassTypeIsCompletelyKnown(
|
||||
type.details.effectiveMetaclass,
|
||||
publicSymbolMap,
|
||||
currentSymbol,
|
||||
typeStack
|
||||
);
|
||||
|
||||
const metaclassDiag = new DiagnosticAddendum();
|
||||
let isMetaclassKnown = true;
|
||||
if (!metaclassInfo.isFullyKnown) {
|
||||
metaclassDiag.addAddendum(metaclassInfo.diag);
|
||||
isMetaclassKnown = false;
|
||||
}
|
||||
|
||||
metaclassInfo.classFields?.forEach((info) => {
|
||||
if (!info.isFullyKnown) {
|
||||
metaclassDiag.addAddendum(info.diag);
|
||||
isMetaclassKnown = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!isMetaclassKnown) {
|
||||
metaclassDiag.addMessage(
|
||||
`Type of metaclass "${type.details.effectiveMetaclass.details.fullName}" is partially unknown`
|
||||
);
|
||||
diag.addAddendum(metaclassDiag);
|
||||
isKnown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add information for base classes.
|
||||
type.details.baseClasses.forEach((baseClass, index) => {
|
||||
const baseClassDiag = new DiagnosticAddendum();
|
||||
|
Loading…
Reference in New Issue
Block a user