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.379 #644

Merged
merged 20 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2fa3638
Bump webpack from 5.90.1 to 5.94.0 in /packages/pyright (#8845)
dependabot[bot] Aug 28, 2024
ce64adc
Pull Pylance with Pyright 1.1.378 (#8851)
debonte Aug 28, 2024
c979baf
Updated some diagnostic strings to refer to "type expression" rather …
erictraut Aug 30, 2024
a1a83f1
Fixed bug that results in the incorrect type when the `Callable` spec…
erictraut Aug 30, 2024
e43b6af
Incorporated a bunch of code cleanup and refactoring changes from a s…
erictraut Aug 31, 2024
4773ded
Fixed a bug that can result in difficult-to-reproduce type evaluation…
erictraut Sep 1, 2024
689857d
Added provisional support for draft PEP 747 and the `TypeForm` specia…
erictraut Sep 1, 2024
386b7fe
Added check for concatenated bytes and str literals. This addresses #…
erictraut Sep 2, 2024
fe64394
Fix a small typo in Understanding Type Inference (#8877)
ndmitchell Sep 2, 2024
c29f903
Fixed bug that results in incorrect type evaluation when assigning a …
erictraut Sep 2, 2024
354d467
Fixed rename step in Release pipeline (#8882)
bschnurr Sep 3, 2024
7abaf19
Fixed a bug that results in confusing hover information for an attrs …
erictraut Sep 3, 2024
8312965
Published 1.1.379
erictraut Sep 3, 2024
5a50451
Merge tag 'refs/tags/1.1.379' into merge-1.1.379
DetachHead Sep 4, 2024
7f4ffb5
fix type errors due to `getDeclInfoForNameNode` method being removed …
DetachHead Sep 4, 2024
b4c261c
fix mismatching vscode-languageserver version in browser-basedpyright…
DetachHead Sep 4, 2024
57759b1
remove `--force` from npm installs because we are no longer using a p…
DetachHead Sep 4, 2024
09ec86c
update inline typed dict test due to upstream change that caused more…
DetachHead Sep 4, 2024
dd8d055
fix incorrect semantic highlighting of `Never`
DetachHead Sep 4, 2024
6b83eed
update error message in `AbstractContextManager` subscript test
DetachHead Sep 4, 2024
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
9 changes: 8 additions & 1 deletion build/azuredevops/azure-pipelines-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,15 @@ extends:
inputs:
script: |
npm run package
move pyright-*.vsix $(VSIX_NAME)
workingDirectory: packages/vscode-pyright

- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'Move-Item -Path "pyright-*.vsix" -Destination "$(VSIX_NAME)"'
workingDirectory: packages/vscode-pyright
displayName: 'Move VSIX file'

- task: CopyFiles@2
displayName: 'Copy vsix to: build_output'
inputs:
Expand Down
2 changes: 1 addition & 1 deletion docs/type-inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var6 = [p for p in [1, 2, 3]] # Inferred type is list[int]
When a symbol is assigned values in multiple places within the code, those values may have different types. The inferred type of the variable is the union of all such types.

```python
# In this example, symbol var1 has an inferred type of `str | int`]`.
# In this example, symbol var1 has an inferred type of `str | int`.
class Foo:
def __init__(self):
self.var1 = ""
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "1.1.378",
"version": "1.1.379",
"command": {
"version": {
"push": false,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"scripts": {
"postinstall": "node ./build/skipBootstrap.js || npm run install:others",
"clean": "lerna run --no-bail --stream clean",
"install:all": "npm install --force",
"install:others": "cross-env SKIP_LERNA_BOOTSTRAP=yes lerna exec --no-bail npm install -- --force",
"install:all": "npm install",
"install:others": "cross-env SKIP_LERNA_BOOTSTRAP=yes lerna exec --no-bail npm install",
"update:all": "node ./build/updateDeps.js",
"build:extension:dev": "cd packages/vscode-pyright && npm run webpack",
"build:extension": "cd packages/vscode-pyright && npm run package",
Expand Down
36 changes: 16 additions & 20 deletions packages/browser-pyright/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/browser-pyright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"stream-browserify": "^3.0.0",
"util": "^0.12.5",
"vm-browserify": "^1.1.2",
"vscode-languageserver": "10.0.0-next.2"
"vscode-languageserver": "10.0.0-next.10"
}
}
72 changes: 36 additions & 36 deletions packages/pyright-internal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.378",
"version": "1.1.379",
"license": "MIT",
"private": true,
"files": [
Expand Down Expand Up @@ -31,11 +31,11 @@
"pyright-to-gitlab-ci": "^0.1.3",
"source-map-support": "^0.5.21",
"tmp": "^0.2.1",
"vscode-jsonrpc": "^9.0.0-next.2",
"vscode-languageserver": "10.0.0-next.2",
"vscode-languageserver-protocol": "^3.17.6-next.3",
"vscode-jsonrpc": "^9.0.0-next.5",
"vscode-languageserver": "10.0.0-next.10",
"vscode-languageserver-protocol": "^3.17.6-next.10",
"vscode-languageserver-textdocument": "1.0.11",
"vscode-languageserver-types": "^3.17.6-next.3",
"vscode-languageserver-types": "^3.17.6-next.5",
"vscode-uri": "^3.0.8"
},
"devDependencies": {
Expand Down
16 changes: 9 additions & 7 deletions packages/pyright-internal/src/analyzer/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ export class Checker extends ParseTreeWalker {
return false;
}

const decls = this._evaluator.getDeclarationsForNameNode(node.d.name);
const decls = this._evaluator.getDeclInfoForNameNode(node.d.name)?.decls;
if (!decls) {
return false;
}
Expand Down Expand Up @@ -2631,7 +2631,7 @@ export class Checker extends ParseTreeWalker {
// earlier overload. Typeshed stubs contain type: ignore comments on these
// lines, so it is important for us to report them in the same manner.
private _findNodeForOverload(functionNode: FunctionNode, overloadType: FunctionType): FunctionNode | undefined {
const decls = this._evaluator.getDeclarationsForNameNode(functionNode.d.name);
const decls = this._evaluator.getDeclInfoForNameNode(functionNode.d.name)?.decls;
if (!decls) {
return undefined;
}
Expand Down Expand Up @@ -4162,7 +4162,7 @@ export class Checker extends ParseTreeWalker {
isSupported = false;
} else if (
subtype.props?.specialForm &&
isInstantiableClass(subtype.props.specialForm) &&
isClassInstance(subtype.props.specialForm) &&
ClassType.isBuiltIn(subtype.props.specialForm, 'Annotated')
) {
diag.addMessage(LocAddendum.annotatedNotAllowed());
Expand Down Expand Up @@ -4602,8 +4602,8 @@ export class Checker extends ParseTreeWalker {
// any variable declarations that are bound using nonlocal
// or global explicit bindings.
const declarations = this._evaluator
.getDeclarationsForNameNode(node)
?.filter((decl) => decl.type !== DeclarationType.Variable || !decl.isExplicitBinding);
.getDeclInfoForNameNode(node)
?.decls?.filter((decl) => decl.type !== DeclarationType.Variable || !decl.isExplicitBinding);

let primaryDeclaration =
declarations && declarations.length > 0 ? declarations[declarations.length - 1] : undefined;
Expand Down Expand Up @@ -4787,7 +4787,9 @@ export class Checker extends ParseTreeWalker {

if (isTypeIs) {
const scopeIds = getTypeVarScopeIds(functionType);
const typeGuardType = makeTypeVarsBound(returnType.priv.typeArgs[0], scopeIds);
const narrowedType = returnType.priv.typeArgs[0];
let typeGuardType = makeTypeVarsBound(narrowedType, scopeIds);
typeGuardType = TypeBase.cloneWithTypeForm(typeGuardType, typeGuardType);

// Determine the type of the first parameter.
const paramIndex = isMethod && !FunctionType.isStaticMethod(functionType) ? 1 : 0;
Expand All @@ -4805,7 +4807,7 @@ export class Checker extends ParseTreeWalker {
DiagnosticRule.reportGeneralTypeIssues,
LocMessage.typeIsReturnType().format({
type: this._evaluator.printType(paramType),
returnType: this._evaluator.printType(typeGuardType),
returnType: this._evaluator.printType(narrowedType),
}),
returnAnnotation
);
Expand Down
6 changes: 6 additions & 0 deletions packages/pyright-internal/src/analyzer/codeFlowEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,12 @@ export function getCodeFlowEngine(
// type, thus preventing further traversal of the code flow graph.
function isCallNoReturn(evaluator: TypeEvaluator, flowNode: FlowCall) {
const node = flowNode.node;
const fileInfo = getFileInfo(node);

// Assume that calls within a pyi file are not "NoReturn" calls.
if (fileInfo.isStubFile) {
return false;
}

if (enablePrintCallNoReturn) {
console.log(`isCallNoReturn@${flowNode.id} Pre depth ${noReturnAnalysisDepth}`);
Expand Down
5 changes: 3 additions & 2 deletions packages/pyright-internal/src/analyzer/constraintSolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
sortTypes,
specializeTupleClass,
specializeWithDefaultTypeArgs,
stripTypeForm,
transformExpectedType,
transformPossibleRecursiveTypeAlias,
} from './typeUtils';
Expand Down Expand Up @@ -503,7 +504,7 @@ export function addConstraintsForExpectedType(
function stripLiteralsForLowerBound(evaluator: TypeEvaluator, typeVar: TypeVarType, lowerBound: Type) {
return isTypeVarTuple(typeVar)
? stripLiteralValueForUnpackedTuple(evaluator, lowerBound)
: evaluator.stripLiteralValue(lowerBound);
: stripTypeForm(evaluator.stripLiteralValue(lowerBound));
}

function getTypeVarType(
Expand Down Expand Up @@ -1335,7 +1336,7 @@ function stripLiteralValueForUnpackedTuple(evaluator: TypeEvaluator, type: Type)

let strippedLiteral = false;
const tupleTypeArgs: TupleTypeArg[] = type.priv.tupleTypeArgs.map((arg) => {
const strippedType = evaluator.stripLiteralValue(arg.type);
const strippedType = stripTypeForm(evaluator.stripLiteralValue(arg.type));

if (strippedType !== arg.type) {
strippedLiteral = true;
Expand Down
Loading
Loading