Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,13 +1929,13 @@ def anal_type(
self.allow_unpack = old_allow_unpack
if (
not allow_param_spec
and isinstance(analyzed, ParamSpecType)
and analyzed.flavor == ParamSpecFlavor.BARE
and isinstance(analyzed, (ParamSpecType, Parameters))
and (isinstance(analyzed, Parameters) or analyzed.flavor == ParamSpecFlavor.BARE)
):
if analyzed.prefix.arg_types:
is_concatenate = isinstance(analyzed, Parameters) or analyzed.prefix.arg_types
if is_concatenate:
self.fail("Invalid location for Concatenate", t, code=codes.VALID_TYPE)
self.note("You can use Concatenate as the first argument to Callable", t)
analyzed = AnyType(TypeOfAny.from_error)
else:
self.fail(
INVALID_PARAM_SPEC_LOCATION.format(format_type(analyzed, self.options)),
Expand All @@ -1947,7 +1947,7 @@ def anal_type(
t,
code=codes.VALID_TYPE,
)
analyzed = AnyType(TypeOfAny.from_error)
analyzed = AnyType(TypeOfAny.from_error)
return analyzed

def anal_var_def(self, var_def: TypeVarLikeType) -> TypeVarLikeType:
Expand Down
1 change: 1 addition & 0 deletions test-data/unit/check-parameter-specification.test
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ from typing import Callable
P = ParamSpec("P")

def x(f: Callable[Concatenate[int, Concatenate[int, P]], None]) -> None: ... # E: Nested Concatenates are invalid
def y(f: Callable[Concatenate[Concatenate[...], ...], None]) -> None: ... # E: Invalid location for Concatenate # N: You can use Concatenate as the first argument to Callable
[builtins fixtures/paramspec.pyi]

[case testPropagatedAnyConstraintsAreOK]
Expand Down
7 changes: 0 additions & 7 deletions test-data/unit/check-tuples.test
Original file line number Diff line number Diff line change
Expand Up @@ -1831,10 +1831,3 @@ class tuple_aa_subclass(Tuple[A, A]): ...

inst_tuple_aa_subclass: tuple_aa_subclass = tuple_aa_subclass((A(), A()))[:] # E: Incompatible types in assignment (expression has type "tuple[A, A]", variable has type "tuple_aa_subclass")
[builtins fixtures/tuple.pyi]

[case testTuplePassedParameters]
from typing_extensions import Concatenate

def c(t: tuple[Concatenate[int, ...]]) -> None: # E: Cannot use "[int, VarArg(Any), KwArg(Any)]" for tuple, only for ParamSpec
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this old error codepath? I can't imagine a scenario where it's useful...

reveal_type(t) # N: Revealed type is "tuple[Any]"
[builtins fixtures/tuple.pyi]
Loading