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.359 #303

Merged
merged 28 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
98d1523
Expanded support for `len(x) == L` type guard pattern (where x is a t…
erictraut Apr 10, 2024
d45ea4c
Push pylance changes to pyright (#7663)
debonte Apr 10, 2024
27e6b0e
Improved some diagnostic messages, moving away from the term "member"…
erictraut Apr 11, 2024
c212c23
More diagnostic message improvements: switched from "cannot assign to…
erictraut Apr 12, 2024
8c7e67d
Fixed a bug that leads to inconsistent behaviors when an assignment l…
erictraut Apr 12, 2024
dd09712
Extended type narrowing logic for `in` and `not in` operators that ta…
erictraut Apr 12, 2024
f2e277a
Fixed recent regression that results in a false positive error when a…
erictraut Apr 12, 2024
92f2284
Changed behavior when evaluating the upper bound expression, value co…
erictraut Apr 12, 2024
dfe4281
Fixed bug that results in a spurious `reportAbstractUsage` error when…
erictraut Apr 13, 2024
d7dce3b
Modified handling of annotated `self` parameter in `__init__` method …
erictraut Apr 13, 2024
567d025
Added missing check for the errant use of class-scoped type variables…
erictraut Apr 13, 2024
975c846
Fixed bug that results in incorrect type evaluation when solving a Pa…
erictraut Apr 14, 2024
1918364
Fixed a bug in bindFunctionToClassOrObject function that resulted in …
erictraut Apr 14, 2024
5c48084
Refactored the logic related to conversion of a class constructor to …
erictraut Apr 14, 2024
00d8f81
Fixed a bug that results in incorrect type evaluation when assigning …
erictraut Apr 14, 2024
2e537e9
Updated logic for converting a class constructor to a callable to con…
erictraut Apr 14, 2024
7f46092
Fixed a bug that leads to a false negative when an unparenthesized as…
erictraut Apr 14, 2024
9d87fe1
Changed the behavior when invoking constructor for `type[T]` where `T…
erictraut Apr 14, 2024
653e160
Modified behavior in constructor call code that previously applied so…
erictraut Apr 14, 2024
74880b8
Fixed broken build. I forgot to check in a test change.
erictraut Apr 14, 2024
43fe9a7
Changed behavior of conversion from class constructor to callable to …
erictraut Apr 14, 2024
71a3b60
Changed behavior of conversion from class constructor to callable to …
erictraut Apr 14, 2024
b1c4368
Changed behavior of conversion from class constructor to callable to …
erictraut Apr 14, 2024
8a7aed5
Added a check for the case where a frozen dataclass overrides a field…
erictraut Apr 14, 2024
8912c88
Fixed bug that results in false positive error under certain circumst…
erictraut Apr 16, 2024
cc3467f
Published 1.1.359
erictraut Apr 17, 2024
85963c4
Merge tag '1.1.359' into merge-1.1.359
DetachHead Apr 17, 2024
f7af25f
update lockfiles
DetachHead Apr 17, 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
2 changes: 1 addition & 1 deletion docs/type-concepts-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ In addition to assignment-based type narrowing, Pyright supports the following t
* `x[I] == V` and `x[I] != V` (where I and V are literal expressions and x is a known-length tuple that is distinguished by the index indicated by I)
* `x[I] is B` and `x[I] is not B` (where I is a literal expression, B is a `bool` or enum literal, and x is a known-length tuple that is distinguished by the index indicated by I)
* `x[I] is None` and `x[I] is not None` (where I is a literal expression and x is a known-length tuple that is distinguished by the index indicated by I)
* `len(x) == L` and `len(x) != L` (where x is tuple and L is an expression that evaluates to an int literal type)
* `len(x) == L`, `len(x) != L`, `len(x) < L`, etc. (where x is tuple and L is an expression that evaluates to an int literal type)
* `x in y` or `x not in y` (where y is instance of list, set, frozenset, deque, tuple, dict, defaultdict, or OrderedDict)
* `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)
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.358",
"version": "1.1.359",
"command": {
"version": {
"push": false,
Expand Down
38 changes: 10 additions & 28 deletions packages/pyright-internal/package-lock.json

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

4 changes: 2 additions & 2 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.358",
"version": "1.1.359",
"license": "MIT",
"private": true,
"files": [
Expand All @@ -27,7 +27,7 @@
"chokidar": "^3.6.0",
"command-line-args": "^5.2.1",
"jsonc-parser": "^3.2.1",
"leven": "^3.1.0",
"leven": "3.1.0",
"pyright-to-gitlab-ci": "^0.1.3",
"source-map-support": "^0.5.21",
"tmp": "^0.2.1",
Expand Down
23 changes: 23 additions & 0 deletions packages/pyright-internal/src/analyzer/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3148,9 +3148,32 @@ export class Binder extends ParseTreeWalker {

// Look for "X is Y" or "X is not Y".
// Look for X == <literal> or X != <literal>
// Look for len(X) == <literal> or len(X) != <literal>
return isLeftNarrowing;
}

// Look for len(X) < <literal>, len(X) <= <literal>, len(X) > <literal>, len(X) >= <literal>.
if (
expression.rightExpression.nodeType === ParseNodeType.Number &&
expression.rightExpression.isInteger
) {
if (
expression.operator === OperatorType.LessThan ||
expression.operator === OperatorType.LessThanOrEqual ||
expression.operator === OperatorType.GreaterThan ||
expression.operator === OperatorType.GreaterThanOrEqual
) {
const isLeftNarrowing = this._isNarrowingExpression(
expression.leftExpression,
expressionList,
filterForNeverNarrowing,
/* isComplexExpression */ true
);

return isLeftNarrowing;
}
}

// Look for "<string> in Y" or "<string> not in Y".
if (expression.operator === OperatorType.In || expression.operator === OperatorType.NotIn) {
if (
Expand Down
Loading
Loading