Skip to content

Commit

Permalink
Fixed bug that resulted in a false positive error when defining a new…
Browse files Browse the repository at this point in the history
… type alias using the `TypeAliasType` constructor that defines no new type parameters but references an outer-scoped type parameter in the type alias definition. This addresses #5341.
  • Loading branch information
msfterictraut committed Jun 19, 2023
1 parent d816d00 commit b7df200
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/typeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12009,7 +12009,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
nameNode,
valueExpr,
/* typeParamNodes */ undefined,
() => typeParameters
() => typeParameters ?? []
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This sample tests the TypeAliasType constructor.

from typing import Callable, ParamSpec, TypeVar, TypeVarTuple
from typing import Callable, Generic, ParamSpec, TypeVar, TypeVarTuple
from typing_extensions import TypeAliasType

T1 = TypeVar("T1")
Expand Down Expand Up @@ -45,3 +45,7 @@
TA7 = TypeAliasType("TA7", TA6)

JSONNode = TypeAliasType("JSONNode", list[JSONNode] | dict[str, JSONNode] | str | float)


class A(Generic[T]):
L = TypeAliasType("L", list[T])

0 comments on commit b7df200

Please sign in to comment.