Skip to content
Merged
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
5 changes: 5 additions & 0 deletions pytype/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,11 @@ def _check_type_param_consistency(
for old_value in old_concrete_values:
if self._satisfies_common_superclass([new_value, old_value]):
has_error = False
elif isinstance(old_value, function.ParamSpecMatch):
# TODO - Technically we need to check the type parameter against
# ParamSpec to check case the restrictions are different, but it
# seems we don't have the machinery to check that yet in pytype.
has_error = False
elif old_value.cls.is_protocol:
with self._track_partially_matched_protocols():
protocol_subst = datatypes.AliasingDict(subst)
Expand Down
17 changes: 17 additions & 0 deletions pytype/tests/test_typevar2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,23 @@ def f(self, x: T) -> T:
return x
""")

def test_check_type_param_against_param_spec(self):
self.Check("""
import multiprocessing.pool
from typing import Callable, ParamSpec, TypeVar, Any
_T = TypeVar('_T')
_Args = ParamSpec('_Args')

def decorator() -> Callable[[Callable[_Args, _T]], Callable[_Args, _T]]:
pass # pytype: disable=bad-return-type
def foo():
@decorator()
def f(i: int):
return i
with multiprocessing.pool.ThreadPool(10) as pool:
a: list[Any] = pool.map(f, list(range(10))) # TODO: Should be list[int]
""")


if __name__ == "__main__":
test_base.main()
Loading