Skip to content

Commit

Permalink
Merge tag 'refs/tags/1.1.380' into merge-1.1.380
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts
#	packages/pyright-internal/src/workspaceFactory.ts
#	packages/pyright/package-lock.json
#	packages/pyright/package.json
#	packages/vscode-pyright/package.json
  • Loading branch information
DetachHead committed Sep 10, 2024
2 parents 047fc77 + d91a24b commit 370a431
Show file tree
Hide file tree
Showing 171 changed files with 2,970 additions and 1,702 deletions.
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ there are rules in pyright that are discouraged in basedpyright because we provi
## Execution Environment Options
Pyright allows multiple “execution environments” to be defined for different portions of your source tree. For example, a subtree may be designed to run with different import search paths or a different version of the python interpreter than the rest of the source base.

The following settings can be specified for each execution environment.
The following settings can be specified for each execution environment. Each source file within a project is associated with at most one execution environment -- the first one whose root directory contains that file.

- **root** [string, required]: Root path for the code that will execute within this execution environment.

Expand Down Expand Up @@ -482,7 +482,7 @@ note that some settings which are enabled by default in pyright are disabled by

## Overriding settings (in VS Code)

If a pyproject.toml (with a pyright section) or a pyrightconfig.json exists, any pyright settings in a VS code setttings.json will be ignored. Pyrightconfig.json is prescribing the environment to be used for a particular project. Changing the environment per user is not supported.
If a pyproject.toml (with a pyright section) or a pyrightconfig.json exists, any pyright settings in a VS Code setttings.json will be ignored. Pyrightconfig.json is prescribing the environment to be used for a particular project. Changing the environment configuration options per user is not supported.

If a pyproject.toml (with a pyright section) or a pyrightconfig.json does not exist, then the VS Code settings.json settings apply.

Expand All @@ -497,4 +497,4 @@ LANG="zh-cn"
LANGUAGE="fr"
```

When running in VS Code, the IDE's locale takes precedence. Setting these environment variables applies only when using pyright outside of VS code.
When running in VS Code, the editor's locale takes precedence. Setting these environment variables applies only when using pyright outside of VS Code.
1 change: 0 additions & 1 deletion docs/type-concepts-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ In addition to assignment-based type narrowing, Pyright supports the following t
* `S in D` and `S not in D` (where S is a string literal and D is a TypedDict)
* `isinstance(x, T)` (where T is a type or a tuple of types)
* `issubclass(x, T)` (where T is a type or a tuple of types)
* `callable(x)`
* `f(x)` (where f is a user-defined type guard as defined in [PEP 647](https://www.python.org/dev/peps/pep-0647/) or [PEP 742](https://www.python.org/dev/peps/pep-0742))
* `bool(x)` (where x is any expression that is statically verifiable to be truthy or falsey in all cases)
* `x` (where x is any expression that is statically verifiable to be truthy or falsey in all cases)
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.379",
"version": "1.1.380",
"command": {
"version": {
"push": false,
Expand Down
4 changes: 2 additions & 2 deletions packages/pyright-internal/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/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.379",
"version": "1.1.380",
"license": "MIT",
"private": true,
"files": [
Expand Down
24 changes: 16 additions & 8 deletions packages/pyright-internal/src/analyzer/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1501,14 +1501,11 @@ export class Binder extends ParseTreeWalker {
this._targetFunctionDeclaration.raiseStatements.push(node);
}

if (node.d.typeExpression) {
this.walk(node.d.typeExpression);
}
if (node.d.valueExpression) {
this.walk(node.d.valueExpression);
if (node.d.expr) {
this.walk(node.d.expr);
}
if (node.d.tracebackExpression) {
this.walk(node.d.tracebackExpression);
if (node.d.fromExpr) {
this.walk(node.d.fromExpr);
}

this._finallyTargets.forEach((target) => {
Expand Down Expand Up @@ -2271,7 +2268,18 @@ export class Binder extends ParseTreeWalker {
this.walk(node.d.expr);

const expressionList: CodeFlowReferenceExpressionNode[] = [];
const isSubjectNarrowable = this._isNarrowingExpression(node.d.expr, expressionList);
let isSubjectNarrowable = this._isNarrowingExpression(node.d.expr, expressionList);

// We also support narrowing of individual tuple entries found within a
// match subject expression, so add those here as well.
if (node.d.expr.nodeType === ParseNodeType.Tuple) {
node.d.expr.d.items.forEach((itemExpr) => {
if (this._isNarrowingExpression(itemExpr, expressionList)) {
isSubjectNarrowable = true;
}
});
}

if (isSubjectNarrowable) {
expressionList.forEach((expr) => {
const referenceKey = createKeyForReference(expr);
Expand Down
Loading

0 comments on commit 370a431

Please sign in to comment.