|
13 | 13 | AnyType, |
14 | 14 | CallableType, |
15 | 15 | Instance, |
16 | | - ParamSpecFlavor, |
17 | 16 | ParamSpecType, |
18 | 17 | ProperType, |
19 | 18 | TupleType, |
@@ -246,9 +245,6 @@ def expand_actual_type( |
246 | 245 | return item |
247 | 246 | elif isinstance(star_args_type, ParamSpecType): |
248 | 247 | # ParamSpec is valid in *args but it can't be unpacked. |
249 | | - assert ( |
250 | | - star_args_type.flavor == ParamSpecFlavor.ARGS |
251 | | - ), f"ParamSpecType for *args should have ARGS flavor, got {star_args_type.flavor}" |
252 | 248 | return star_args_type |
253 | 249 | else: |
254 | 250 | return AnyType(TypeOfAny.from_error) |
@@ -390,17 +386,12 @@ def parse_star_args_type( |
390 | 386 | ) -> TupleType | IterableType | ParamSpecType | AnyType: |
391 | 387 | """Parse the type of a ``*args`` argument. |
392 | 388 |
|
393 | | - Returns one of TupleType, IterableType, ParamSpecType (ARGS flavor), |
394 | | - or AnyType(TypeOfAny.from_error) if the type cannot be parsed or is invalid. |
| 389 | + Returns one of TupleType, TupleInstance or AnyType. |
395 | 390 | """ |
396 | 391 | p_t = get_proper_type(typ) |
397 | | - if isinstance(p_t, (TupleType, AnyType)): |
| 392 | + if isinstance(p_t, (TupleType, ParamSpecType, AnyType)): |
398 | 393 | # just return the type as-is |
399 | 394 | return p_t |
400 | | - elif isinstance(p_t, ParamSpecType): |
401 | | - if p_t.flavor == ParamSpecFlavor.ARGS: |
402 | | - return p_t |
403 | | - return AnyType(TypeOfAny.from_error) |
404 | 395 | elif isinstance(p_t, TypeVarTupleType): |
405 | 396 | return self.parse_star_args_type(p_t.upper_bound) |
406 | 397 | elif isinstance(p_t, UnionType): |
|
0 commit comments