Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 1.1.392 #996

Merged
merged 23 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1f5a2bc
Changed error messages to refer to lowercase `list`, `dict` and `type…
erictraut Dec 18, 2024
e643c25
pull-pylance-with-pyright-1.1.391-20241218-032433 (#9598)
bschnurr Dec 18, 2024
db368a1
Fixed bug that results in incorrect evaluation when passing a callabl…
erictraut Dec 25, 2024
8f35aa0
Fixed bug that results in the `extraPaths` configuration option withi…
erictraut Dec 28, 2024
a03e8e4
Fixed bug in dictionary expression type inference that results in the…
erictraut Jan 2, 2025
a254b79
Improved handling of `__getitem__`, `__setitem__` and `__delitem__` m…
erictraut Jan 3, 2025
97da18a
Code cleanup: Removed unused parameter from getGetterTypeFromProperty…
erictraut Jan 3, 2025
0f57009
Eliminated type evaluation order dependency that results from return …
erictraut Jan 3, 2025
b0bd5bf
fixed Uri to use value check rather than reference check. (#9665)
heejaechang Jan 7, 2025
cba1872
Added missing syntax error check for positional argument that follows…
erictraut Jan 8, 2025
36a58cd
pull-pylance-with-pyright-1.1.391-20250108-044808 (#9673)
bschnurr Jan 8, 2025
d0210f6
Changed code that computes unescaped literal string type to convert C…
erictraut Jan 10, 2025
14b3c70
Improved error reporting for "async with" statement. Added check that…
erictraut Jan 13, 2025
fb7989c
Fixed bug that results in an incorrect "overlapping overload" error m…
erictraut Jan 14, 2025
4d8b903
Fixed bug that results in a spurious error when an assignment express…
erictraut Jan 14, 2025
1593a7c
Fixed bug that results in a spurious "incompatible method override" e…
erictraut Jan 14, 2025
575c639
Improved type narrowing for `issubclass` in the negative ("else") cas…
erictraut Jan 14, 2025
c1edc0b
Added support for bidirectional type inference for assignment stateme…
erictraut Jan 14, 2025
c7b2fb9
Fixed bug that results in an "incompatible method override" false neg…
erictraut Jan 14, 2025
2b126fa
Published 1.1.392
erictraut Jan 15, 2025
c4487e2
Merge tag '1.1.392' into merge-1.1.392
DetachHead Jan 15, 2025
844634e
npm dependency updates from upstream
DetachHead Jan 15, 2025
090ac3e
fail
DetachHead Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
293 changes: 142 additions & 151 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"devDependencies": {
"@detachhead/ts-helpers": "^16.2.0",
"@types/glob": "^7.2.0",
"@types/node": "^22.7.0",
"@types/node": "^22.10.5",
"@types/yargs": "^16.0.9",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/browser-pyright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
},
"devDependencies": {
"@types/copy-webpack-plugin": "^8.0.1",
"@types/node": "^22.7.0",
"@types/node": "^22.10.5",
"copy-webpack-plugin": "^11.0.0",
"shx": "^0.3.4",
"ts-loader": "^9.5.1",
"typescript": "~5.5.4",
"webpack": "^5.94.0",
"webpack": "^5.97.1",
"webpack-cli": "^5.1.4",
"webpack-virtual-modules": "^0.6.2"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/pyright-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pyright-internal",
"displayName": "pyright",
"description": "Type checker for the Python language",
"version": "1.1.391",
"version": "1.1.392",
"license": "MIT",
"private": true,
"files": [
Expand Down Expand Up @@ -43,9 +43,9 @@
"@types/command-line-args": "^5.2.3",
"@types/diff": "^5.2.2",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.13",
"@types/lodash": "^4.17.7",
"@types/node": "^22.7.0",
"@types/jest": "^29.5.14",
"@types/lodash": "^4.17.14",
"@types/node": "^22.10.5",
"@types/tmp": "^0.2.6",
"copy-webpack-plugin": "^11.0.0",
"esbuild-loader": "^3.2.0",
Expand All @@ -56,7 +56,7 @@
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"typescript": "~5.5.4",
"webpack": "^5.94.0",
"webpack": "^5.97.1",
"webpack-cli": "^5.1.4",
"word-wrap": "1.2.5"
}
Expand Down
25 changes: 5 additions & 20 deletions packages/pyright-internal/src/analyzer/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5978,34 +5978,18 @@ export class Checker extends ParseTreeWalker {

if (isFunction(overriddenType) || isOverloaded(overriddenType)) {
const diagAddendum = new DiagnosticAddendum();
let overrideFunction: FunctionType | undefined;

if (isFunction(overrideType)) {
overrideFunction = overrideType;
} else if (isOverloaded(overrideType)) {
// Use the last overload.
const impl = OverloadedType.getImplementation(overrideType);

// If the last overload isn't an implementation, skip the check for this symbol.
if (!impl || !isFunction(impl)) {
return;
}

overrideFunction = impl;
}

if (overrideFunction) {
if (isFunction(overrideType) || isOverloaded(overrideType)) {
if (
!this._evaluator.validateOverrideMethod(
overriddenType,
overrideFunction,
overrideType,
/* baseClass */ undefined,
diagAddendum,
/* enforceParamNameMatch */ true
)
) {
const decl = overrideFunction.shared.declaration;
if (decl && decl.type === DeclarationType.Function) {
if (overrideDecl && overrideDecl.type === DeclarationType.Function) {
diag = this._evaluator.addDiagnostic(
DiagnosticRule.reportIncompatibleMethodOverride,
LocMessage.baseClassMethodTypeIncompatible().format({
Expand Down Expand Up @@ -6745,7 +6729,7 @@ export class Checker extends ParseTreeWalker {
selfSpecializeClass(childClassType, { useBoundTypeVars: true })
);

const baseType = partiallySpecializeType(
let baseType = partiallySpecializeType(
this._evaluator.getEffectiveTypeOfSymbol(baseClassAndSymbol.symbol),
baseClass,
this._evaluator.getTypeClassType(),
Expand All @@ -6761,6 +6745,7 @@ export class Checker extends ParseTreeWalker {

if (childClassType.shared.typeVarScopeId) {
overrideType = makeTypeVarsBound(overrideType, [childClassType.shared.typeVarScopeId]);
baseType = makeTypeVarsBound(baseType, [childClassType.shared.typeVarScopeId]);
}

if (isFunction(baseType) || isOverloaded(baseType)) {
Expand Down
24 changes: 14 additions & 10 deletions packages/pyright-internal/src/analyzer/constructors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,20 @@ function validateNewMethod(

const constraints = new ConstraintTracker();

const callResult = evaluator.useSpeculativeMode(useSpeculativeModeForArgs ? errorNode : undefined, () => {
return evaluator.validateCallArgs(
errorNode,
argList,
newMethodTypeResult,
constraints,
skipUnknownArgCheck,
inferenceContext
);
});
const callResult = evaluator.useSpeculativeMode(
useSpeculativeModeForArgs ? errorNode : undefined,
() => {
return evaluator.validateCallArgs(
errorNode,
argList,
newMethodTypeResult,
constraints,
skipUnknownArgCheck,
inferenceContext
);
},
{ dependentType: newMethodTypeResult.type }
);

if (callResult.isTypeIncomplete) {
isTypeIncomplete = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { TokenType } from '../parser/tokenizerTypes';
import * as AnalyzerNodeInfo from './analyzerNodeInfo';
import { ModuleNameAndType } from './importResolver';
import { ImportResult, ImportType } from './importResult';
import { findTokenAfter, getTokenAt } from './parseTreeUtils';
import { getTokenAfter, getTokenAt } from './parseTreeUtils';
import * as SymbolNameUtils from './symbolNameUtils';

export interface ImportStatement {
Expand Down Expand Up @@ -797,8 +797,8 @@ function getEditsPreservingFirstCommentAfterCommaIfExist(
return [{ start: offsetOfPreviousNodeEnd, length }];
}

const commaToken = findTokenAfter(
parseFileResults.tokenizerOutput,
const commaToken = getTokenAfter(
parseFileResults.tokenizerOutput.tokens,
TextRange.getEnd(previousNode),
(t) => t.type === TokenType.Comma
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class ParentDirectoryCache {
this._libPathCache ??
this._importRootGetter()
.map((r) => fs.realCasePath(r))
.filter((r) => r !== root)
.filter((r) => !r.equals(root))
.filter((r) => r.startsWith(root));

if (this._libPathCache.some((p) => sourceFileUri.startsWith(p))) {
Expand Down
47 changes: 29 additions & 18 deletions packages/pyright-internal/src/analyzer/parseTreeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,35 @@ export function getTokenAtLeft(
return tokens.getItemAt(index);
}

export function getTokenIndexAfter(
tokens: TextRangeCollection<Token>,
position: number,
predicate: (t: Token) => boolean
) {
const index = tokens.getItemAtPosition(position);
if (index < 0) {
return -1;
}

for (let i = index; i < tokens.length; i++) {
const token = tokens.getItemAt(i);
if (predicate(token)) {
return i;
}
}

return -1;
}

export function getTokenAfter(tokens: TextRangeCollection<Token>, position: number, predicate: (t: Token) => boolean) {
const index = getTokenIndexAfter(tokens, position, predicate);
if (index < 0) {
return undefined;
}

return tokens.getItemAt(index);
}

export function isWhitespace(token: Token) {
return token.type === TokenType.NewLine || token.type === TokenType.Indent || token.type === TokenType.Dedent;
}
Expand Down Expand Up @@ -1941,24 +1970,6 @@ export function getIndexOfTokenOverlapping(tokens: TextRangeCollection<Token>, p
return TextRange.overlaps(token, position) ? index : -1;
}

export function findTokenAfter(tokenizerOutput: TokenizerOutput, offset: number, predicate: (t: Token) => boolean) {
const tokens = tokenizerOutput.tokens;

const index = tokens.getItemAtPosition(offset);
if (index < 0) {
return undefined;
}

for (let i = index; i < tokens.length; i++) {
const token = tokens.getItemAt(i);
if (predicate(token)) {
return token;
}
}

return undefined;
}

export function getCommentsAtTokenIndex(tokens: TextRangeCollection<Token>, index: number) {
let token = getTokenAtIndex(tokens, index);
if (!token) {
Expand Down
3 changes: 2 additions & 1 deletion packages/pyright-internal/src/analyzer/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,8 @@ export class Program {
this._importResolver,
this._configOptions,
this.serviceProvider,
new LogTracker(this._console, 'Cloned')
new LogTracker(this._console, 'Cloned'),
this._disableChecker
);

// Cloned program will use whatever user files the program currently has.
Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function clonePropertyWithSetter(
const typeAnnotation = getTypeAnnotationForParam(errorNode, 1);
if (typeAnnotation) {
// Verify consistency of the type.
const fgetType = evaluator.getGetterTypeFromProperty(classType, /* inferTypeIfNeeded */ false);
const fgetType = evaluator.getGetterTypeFromProperty(classType);
if (fgetType && !isAnyOrUnknown(fgetType)) {
const fsetType = evaluator.getTypeOfAnnotation(typeAnnotation, {
typeVarGetsCurScope: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ function assignToProtocolInternal(
}
} else {
// Extract the property type from the property class.
let getterType = evaluator.getGetterTypeFromProperty(destMemberType, /* inferTypeIfNeeded */ true);
let getterType = evaluator.getGetterTypeFromProperty(destMemberType);

if (getterType) {
getterType = partiallySpecializeType(getterType, mroClass, evaluator.getTypeClassType());
Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/typeCacheUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface SpeculativeModeOptions {
// a context is popped off the stack, all of the speculative type cache
// entries that were created within that context are removed from the
// corresponding type caches because they are no longer valid.
// Each type context also contains a map of "speculative types" that are
// The tracker also also contains a map of "speculative types" that are
// contextually evaluated based on an "expected type" and potentially
// one or more "dependent types". The "expected type" applies in cases
// where the speculative root node is being evaluated with bidirectional
Expand Down
Loading
Loading