Skip to content

Commit

Permalink
Plumb the absoluteTypeNames flag through
Browse files Browse the repository at this point in the history
Define it as defaulting to `false` except for strict diagnostics
  • Loading branch information
necaris committed Mar 20, 2021
1 parent b405ba1 commit 433f3d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/pyright-internal/src/analyzer/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ export class Program {
flags |= PrintTypeFlags.OmitUnannotatedParamType;
}

if (configOptions.diagnosticRuleSet.absoluteTypeNames) {
flags |= PrintTypeFlags.absoluteTypeNames;
}

if (configOptions.diagnosticRuleSet.pep604Printing) {
flags |= PrintTypeFlags.PEP604;
}
Expand Down
7 changes: 7 additions & 0 deletions packages/pyright-internal/src/common/configOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export interface DiagnosticRuleSet {
// Should parameter type be omitted if it is not annotated?
omitUnannotatedParamType: boolean;

// Should we print "absolute" type names e.g. "asyncio.futures.Future" instead of "Future"?
absoluteTypeNames: boolean;

// Should Union and Optional types be printed in PEP 604 format?
pep604Printing: boolean;

Expand Down Expand Up @@ -331,6 +334,7 @@ export function getOffDiagnosticRuleSet(): DiagnosticRuleSet {
printUnknownAsAny: true,
omitTypeArgsIfAny: true,
omitUnannotatedParamType: true,
absoluteModuleNames: false,
pep604Printing: true,
strictListInference: false,
strictDictionaryInference: false,
Expand Down Expand Up @@ -394,6 +398,7 @@ export function getBasicDiagnosticRuleSet(): DiagnosticRuleSet {
printUnknownAsAny: false,
omitTypeArgsIfAny: false,
omitUnannotatedParamType: true,
absoluteModuleNames: false,
pep604Printing: true,
strictListInference: false,
strictDictionaryInference: false,
Expand Down Expand Up @@ -457,6 +462,7 @@ export function getStrictDiagnosticRuleSet(): DiagnosticRuleSet {
printUnknownAsAny: false,
omitTypeArgsIfAny: false,
omitUnannotatedParamType: false,
absoluteModuleNames: true,
pep604Printing: true,
strictListInference: true,
strictDictionaryInference: true,
Expand Down Expand Up @@ -796,6 +802,7 @@ export class ConfigOptions {
printUnknownAsAny: defaultSettings.printUnknownAsAny,
omitTypeArgsIfAny: defaultSettings.omitTypeArgsIfAny,
omitUnannotatedParamType: defaultSettings.omitUnannotatedParamType,
absoluteTypeNames: defaultSettings.absoluteTypeNames,
pep604Printing: defaultSettings.pep604Printing,

// Use strict inference rules for list expressions?
Expand Down

0 comments on commit 433f3d4

Please sign in to comment.