Skip to content

Commit

Permalink
Fixed bug that resulted in a false positive error if a PEP-695 type
Browse files Browse the repository at this point in the history
… statement uses a type parameter and encloses the RHS in quotes. This addresses #7538.
  • Loading branch information
erictraut committed Mar 21, 2024
1 parent a6e787f commit 3da27fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/pyright-internal/src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,10 @@ export class Parser {
this._getNextToken();
}

const wasParsingTypeAnnotation = this._isParsingTypeAnnotation;
this._isParsingTypeAnnotation = true;
const expression = this._parseTestExpression(/* allowAssignmentExpression */ false);
this._isParsingTypeAnnotation = wasParsingTypeAnnotation;

return TypeAliasNode.create(typeToken, name, expression, typeParameters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ def func3(cb: TA11):
def func4():
# This should generate an error.
type TA12 = int


type TA12[T] = "list[T]"
ta12: TA12[int] = [1, 2, 3]

0 comments on commit 3da27fd

Please sign in to comment.