Skip to content

Substitution does not work after ParamSpec substitution of the user generic with a list of TypeVars #88965

Closed

Description

@serhiy-storchaka
BPO 44802
Nosy @gvanrossum, @serhiy-storchaka, @Fidget-Spinner

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-08-01.11:37:51.360>
labels = ['type-bug', 'library', '3.10', '3.11']
title = 'Substitution does not work after ParamSpec substitution of the user generic with a list of TypeVars'
updated_at = <Date 2021-08-01.11:37:51.360>
user = 'https://github.com/serhiy-storchaka'

bugs.python.org fields:

activity = <Date 2021-08-01.11:37:51.360>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-08-01.11:37:51.360>
creator = 'serhiy.storchaka'
dependencies = []
files = []
hgrepos = []
issue_num = 44802
keywords = []
message_count = 1.0
messages = ['398694']
nosy_count = 3.0
nosy_names = ['gvanrossum', 'serhiy.storchaka', 'kj']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue44802'
versions = ['Python 3.10', 'Python 3.11']

Linked PRs

Activity

  1. serhiy-storchaka commented on Aug 1, 2021

    @serhiy-storchaka
    MemberAuthor

    If the user generic with ParamSpec parameter substituted with a parametrised list containing TypeVar, that TypeVar cannot be substituted.

    >>> from typing import *
    >>> T = TypeVar("T")
    >>> P = ParamSpec("P")
    >>> class X(Generic[P]):
    ...     f: Callable[P, int]
    ... 
    >>> Y = X[[int, T]]
    >>> Y
    __main__.X[(<class 'int'>, ~T)]
    >>> Y[str]
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/serhiy/py/cpython/Lib/typing.py", line 309, in inner
        return func(*args, **kwds)
               ^^^^^^^^^^^^^^^^^^^
      File "/home/serhiy/py/cpython/Lib/typing.py", line 1028, in __getitem__
        _check_generic(self, params, len(self.__parameters__))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/serhiy/py/cpython/Lib/typing.py", line 228, in _check_generic
        raise TypeError(f"{cls} is not a generic class")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: __main__.X[(<class 'int'>, ~T)] is not a generic class

    Expected result equal to X[[int, str]].

  2. added
    3.11only security fixes
    stdlibStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or error
    on Aug 1, 2021
  3. transferred this issue fromon Apr 10, 2022
  4. LeeeeT commented on Nov 11, 2022

    @LeeeeT

    Hi there! I'm experiencing the same issue. Will this be fixed? @serhiy-storchaka

  5. added a commit that references this issue on Mar 18, 2023
  6. added a commit that references this issue on Mar 23, 2023
  7. added a commit that references this issue on Mar 23, 2023
  8. AlexWaygood commented on Mar 23, 2023

    @AlexWaygood
    Member

    Fixed on main and 3.11, but we've decided not to backport to 3.10.

  9. added a commit that references this issue on Mar 23, 2023
  10. LeeeeT commented on Mar 23, 2023

    @LeeeeT

    Thanks! You guys are awesome! ❤️

  11. AlexWaygood commented on Mar 23, 2023

    @AlexWaygood
    Member

    Thanks! You guys are awesome! ❤️

    @sobolevn gets all the credit on this one :)

  12. added a commit that references this issue on Mar 27, 2023
  13. added a commit that references this issue on Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

3.10 (EOL)end of life3.11only security fixes3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions