Skip to content

Commit

Permalink
Fix a ParamSpec unit test
Browse files Browse the repository at this point in the history
Summary:
I mistakenly thought that I got an error on callable types like this error:

'Invalid type [31]: Expression `typing.Callable[(L, M)]` is not a valid type.'

This is not true. What's happening is that the program typechecks if we express the type like this:

`Invalid type [31]: Expression `typing.Callable[([L], M)]` is not a valid type.`. So we replaced `L` with `[L]`.

It's unclear yet why this is happening but this should be fixed.

Reviewed By: yangdanny97

Differential Revision: D63842256

fbshipit-source-id: 4c689f0b28b72612740f41e2528a8ae520cf94d4
  • Loading branch information
migeed-z authored and facebook-github-bot committed Oct 4, 2024
1 parent 9a14358 commit a365097
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions source/analysis/test/integration/typeVariableTest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,17 @@ let test_type_variable_scoping =

|}
[];
(* TODO migeedz: Consider what we want to do about this. The conformance test says that we
should not return any errors, but Pyre does not accept such programs in legacy syntax
currently. *)
(* TODO migeedz: Why do we need to express the domain of Callable as a list for this to
typecheck? *)
labeled_test_case __FUNCTION__ __LINE__
@@ assert_type_errors
{|
from typing import Callable
from typing import Callable, ParamSpec

def decorator2[**P, R](x: int) -> Callable[[Callable[P, R]], Callable[P, R]]:
def decorator3[**L, M](x: Callable[L, M]) -> int:
...

|}
[
"Invalid type [31]: Expression `typing.Callable[([typing.Callable[(P, R)]], \
typing.Callable[(P, R)])]` is not a valid type.";
];
["Invalid type [31]: Expression `typing.Callable[(L, M)]` is not a valid type."];
(* PEP695 generic methods from non-generic classes *)
labeled_test_case __FUNCTION__ __LINE__
@@ assert_type_errors
Expand Down

0 comments on commit a365097

Please sign in to comment.