mirror of https://github.com/astral-sh/ruff
unbound `ParamSpec`s should be reported as invalid-type-arguments errors
This commit is contained in:
parent
bbcbaac06f
commit
41e30cc86d
|
|
@ -251,7 +251,7 @@ reveal_type(OnlyParamSpec[...]().attr) # revealed: (...) -> None
|
|||
def func(c: Callable[P2, None]):
|
||||
reveal_type(OnlyParamSpec[P2]().attr) # revealed: (**P2@func) -> None
|
||||
|
||||
# error: [invalid-type-form] "ParamSpec `P2` is unbound"
|
||||
# error: [invalid-type-arguments] "ParamSpec `P2` is unbound"
|
||||
reveal_type(OnlyParamSpec[P2]().attr) # revealed: (...) -> None
|
||||
|
||||
# error: [invalid-type-arguments] "No type argument provided for required type variable `P1` of class `OnlyParamSpec`"
|
||||
|
|
@ -295,7 +295,7 @@ reveal_type(TypeVarAndParamSpec[int, [int, str]]().attr) # revealed: (int, str,
|
|||
reveal_type(TypeVarAndParamSpec[int, [str]]().attr) # revealed: (str, /) -> int
|
||||
reveal_type(TypeVarAndParamSpec[int, ...]().attr) # revealed: (...) -> int
|
||||
|
||||
# error: [invalid-type-form] "ParamSpec `P2` is unbound"
|
||||
# error: [invalid-type-arguments] "ParamSpec `P2` is unbound"
|
||||
reveal_type(TypeVarAndParamSpec[int, P2]().attr) # revealed: (...) -> int
|
||||
# error: [invalid-type-arguments] "Type argument for `ParamSpec` must be either a list of types, `ParamSpec`, `Concatenate`, or `...`"
|
||||
reveal_type(TypeVarAndParamSpec[int, int]().attr) # revealed: (...) -> int
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ def func[**P2](c: Callable[P2, None]):
|
|||
|
||||
P2 = ParamSpec("P2")
|
||||
|
||||
# error: [invalid-type-form] "ParamSpec `P2` is unbound"
|
||||
# error: [invalid-type-arguments] "ParamSpec `P2` is unbound"
|
||||
reveal_type(OnlyParamSpec[P2]().attr) # revealed: (...) -> None
|
||||
|
||||
# error: [invalid-type-arguments] "No type argument provided for required type variable `P1` of class `OnlyParamSpec`"
|
||||
|
|
@ -281,7 +281,7 @@ reveal_type(TypeVarAndParamSpec[int, [int, str]]().attr) # revealed: (int, str,
|
|||
reveal_type(TypeVarAndParamSpec[int, [str]]().attr) # revealed: (str, /) -> int
|
||||
reveal_type(TypeVarAndParamSpec[int, ...]().attr) # revealed: (...) -> int
|
||||
|
||||
# error: [invalid-type-form] "ParamSpec `P2` is unbound"
|
||||
# error: [invalid-type-arguments] "ParamSpec `P2` is unbound"
|
||||
reveal_type(TypeVarAndParamSpec[int, P2]().attr) # revealed: (...) -> int
|
||||
# error: [invalid-type-arguments] "Type argument for `ParamSpec` must be"
|
||||
reveal_type(TypeVarAndParamSpec[int, int]().attr) # revealed: (...) -> int
|
||||
|
|
|
|||
|
|
@ -3531,7 +3531,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
|
|||
if known_instance.class(self.db()) == KnownClass::ParamSpec =>
|
||||
{
|
||||
if let Some(diagnostic_builder) =
|
||||
self.context.report_lint(&INVALID_TYPE_FORM, expr)
|
||||
self.context.report_lint(&INVALID_TYPE_ARGUMENTS, expr)
|
||||
{
|
||||
diagnostic_builder.into_diagnostic(format_args!(
|
||||
"ParamSpec `{}` is unbound",
|
||||
|
|
|
|||
Loading…
Reference in New Issue