Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ParamSpec from __parameters__ of most typing generics #88264

Closed
Fidget-Spinner opened this issue May 10, 2021 · 8 comments
Closed

Remove ParamSpec from __parameters__ of most typing generics #88264

Fidget-Spinner opened this issue May 10, 2021 · 8 comments
Assignees
Labels
3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir

Comments

@Fidget-Spinner
Copy link
Member

BPO 44098
Nosy @gvanrossum, @serhiy-storchaka, @ilevkivskyi, @miss-islington, @Fidget-Spinner
PRs
  • bpo-44098: Drop ParamSpec from most __parameters__ in typing generics #26013
  • [3.10] bpo-44098: Drop ParamSpec from most __parameters__ in typing generics (GH-26013) #26091
  • 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 = 'https://github.com/Fidget-Spinner'
    closed_at = <Date 2021-05-14.14:17:17.921>
    created_at = <Date 2021-05-10.09:41:35.969>
    labels = ['library', '3.10', '3.11']
    title = 'Remove ParamSpec from __parameters__ of most typing generics'
    updated_at = <Date 2021-07-31.13:36:10.523>
    user = 'https://github.com/Fidget-Spinner'

    bugs.python.org fields:

    activity = <Date 2021-07-31.13:36:10.523>
    actor = 'serhiy.storchaka'
    assignee = 'kj'
    closed = True
    closed_date = <Date 2021-05-14.14:17:17.921>
    closer = 'kj'
    components = ['Library (Lib)']
    creation = <Date 2021-05-10.09:41:35.969>
    creator = 'kj'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44098
    keywords = ['patch']
    message_count = 8.0
    messages = ['393373', '393589', '393662', '398283', '398300', '398346', '398393', '398641']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'serhiy.storchaka', 'levkivskyi', 'miss-islington', 'kj']
    pr_nums = ['26013', '26091']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44098'
    versions = ['Python 3.10', 'Python 3.11']

    @Fidget-Spinner
    Copy link
    Member Author

    typing.List includes ParamSpec in __parameters__ but the builtin list doesn't. The behavior of the latter is correct, as PEP-612 states that: "As before, parameters_expressions by themselves are not acceptable in places where a type is expected".

    https://www.python.org/dev/peps/pep-0612/#valid-use-locations

    This patch just makes the typing version same as the builtin version by excluding ParamSpec from __parameters__ (except for Concatenate, Callable, and Generic).

    @Fidget-Spinner Fidget-Spinner added 3.10 only security fixes 3.11 only security fixes labels May 10, 2021
    @Fidget-Spinner Fidget-Spinner self-assigned this May 10, 2021
    @Fidget-Spinner Fidget-Spinner added stdlib Python modules in the Lib dir 3.10 only security fixes 3.11 only security fixes labels May 10, 2021
    @Fidget-Spinner Fidget-Spinner self-assigned this May 10, 2021
    @Fidget-Spinner Fidget-Spinner added the stdlib Python modules in the Lib dir label May 10, 2021
    @gvanrossum
    Copy link
    Member

    New changeset c55ff1b by Miss Islington (bot) in branch '3.10':
    bpo-44098: Drop ParamSpec from most __parameters__ in typing generics (GH-26013) (bpo-26091)
    c55ff1b

    @Fidget-Spinner
    Copy link
    Member Author

    All patches have landed. Thanks Guido!

    @serhiy-storchaka
    Copy link
    Member

    I think that List[P] should be illegal at first place.

    @gvanrossum
    Copy link
    Member

    Yeah, but we shouldn't go out of our way to reject it. Especially since in 3.11 we'll likely have something equivalent to PEP-563 or PEP-649 (the SC is thinking deep about this right now) and either of those means that usually it won't be evaluated at all anyway (you'd have to call get_type_hints() with PEP-563, or use __annotations__ with the other).

    @serhiy-storchaka
    Copy link
    Member

    I am writing a patch which generalizes and significantly simplifies the code for type variables and parameter specifications substitution, and opens a way for more runtime validation. But it is incompatible with these changes.

    @Fidget-Spinner
    Copy link
    Member Author

    @serhiy, could you please briefly describe what you are planning? I'm guessing you're generalizing for _TypeVarLike?

    My main concern is that we should have as few differences between builtin and typing types as possible. typing.List is deprecated and set to remove in Python 3.13/14, so I'm hoping the transition will be fairly painless.

    Originally, the builtin types supported ParamSpec, but I removed that in #69635 for various reasons listed in that PR.

    @serhiy-storchaka
    Copy link
    Member

    See bpo-44796.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants