Skip to content

Commit

Permalink
ignore nested untyped modules, fix fuzziness
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizzerinus committed Jan 9, 2025
1 parent 996c18f commit 4be3cb5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4335,7 +4335,7 @@ export class Binder extends ParseTreeWalker {
}

private _ignoreUntypedModule(module: string) {
return this._fileInfo.diagnosticRuleSet.allowedUntypedLibraries.some(x => module.startsWith(x));
return this._fileInfo.diagnosticRuleSet.allowedUntypedLibraries.some(x => (module + ".").startsWith(x + "."));
}
}

Expand Down
6 changes: 5 additions & 1 deletion packages/pyright-internal/src/analyzer/typeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15114,6 +15114,10 @@ export function createTypeEvaluator(
return { type, isIncomplete, typeErrors };
}

function _ignoreUntypedModule(ruleset: DiagnosticRuleSet, module: string) {
return ruleset.allowedUntypedLibraries.some(x => (module + ".").startsWith(x + "."));
}

function reportPossibleUnknownAssignment(
ruleset: DiagnosticRuleSet,
rule: DiagnosticRule,
Expand All @@ -15130,7 +15134,7 @@ export function createTypeEvaluator(
// Or if the object is in an untyped library that was explicitly mentioned.
if (type.shared && "moduleName" in type.shared) {
const moduleName = type.shared.moduleName;
if (ruleset.allowedUntypedLibraries.indexOf(moduleName) > -1) {
if (_ignoreUntypedModule(ruleset, moduleName)) {
return;
}
}
Expand Down

0 comments on commit 4be3cb5

Please sign in to comment.