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

Rename types.Union to types.UnionType #88895

Closed
serhiy-storchaka opened this issue Jul 24, 2021 · 8 comments
Closed

Rename types.Union to types.UnionType #88895

serhiy-storchaka opened this issue Jul 24, 2021 · 8 comments
Labels
3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@serhiy-storchaka
Copy link
Member

BPO 44732
Nosy @gvanrossum, @ambv, @serhiy-storchaka, @JelleZijlstra, @pablogsal, @miss-islington, @AliyevH, @Fidget-Spinner
PRs
  • bpo-44732: Rename types.Union to types.UnionType #27342
  • [3.10] bpo-44732: Rename types.Union to types.UnionType (GH-27342) #27365
  • 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 = <Date 2021-07-26.19:03:15.666>
    created_at = <Date 2021-07-24.09:24:20.429>
    labels = ['interpreter-core', '3.10', '3.11']
    title = 'Rename types.Union to types.UnionType'
    updated_at = <Date 2021-07-26.19:03:15.666>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2021-07-26.19:03:15.666>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-07-26.19:03:15.666>
    closer = 'pablogsal'
    components = ['Interpreter Core']
    creation = <Date 2021-07-24.09:24:20.429>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44732
    keywords = ['patch']
    message_count = 8.0
    messages = ['398128', '398130', '398177', '398185', '398190', '398210', '398238', '398247']
    nosy_count = 8.0
    nosy_names = ['gvanrossum', 'lukasz.langa', 'serhiy.storchaka', 'JelleZijlstra', 'pablogsal', 'miss-islington', 'AliyevH', 'kj']
    pr_nums = ['27342', '27365']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44732'
    versions = ['Python 3.10', 'Python 3.11']

    @serhiy-storchaka
    Copy link
    Member Author

    There are differences between typing.Union and types.Union:

    • typing.Union is indexable, types.Union is not.
    • types.Union is a class, typing.Union is not.

    types.Union corresponds to typing._UnionGenericAlias, not typing.Union. It is confusing that typing.Union and types.Union have the same name. Note also that most classes in the types module have the "Type" suffix: FunctionType, MethodType, ModuleType, etc. I think that it would be better to rename types.Union to types.UnionType.

    @serhiy-storchaka serhiy-storchaka added 3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jul 24, 2021
    @AliyevH
    Copy link
    Mannequin

    AliyevH mannequin commented Jul 24, 2021

    If nobody works on it i would like to fix it

    @AliyevH
    Copy link
    Mannequin

    AliyevH mannequin commented Jul 25, 2021

    should have a deprecation period and if so, how long?

    @pablogsal
    Copy link
    Member

    This is a feature added to 3.10 so if we change it before the release there is no deprecation period needed. On the other hand if we don't get it to 3.10 is going to be much difficult to rename.

    @gvanrossum
    Copy link
    Member

    Agreed. I think we should do it, Serhiy’s reasoning makes sense.

    We should just update the PEP and add a note that this was changed during the beta period.

    @JelleZijlstra
    Copy link
    Member

    I agree that UnionType is marginally better so we should rename it. It doesn't seem worth doing if this doesn't make it in in time for 3.10, though. With the advent of PEP-604 typing.Union will hopefully become irrelevant.

    @ambv
    Copy link
    Contributor

    ambv commented Jul 26, 2021

    New changeset 2b8ad9e by Hasan in branch 'main':
    bpo-44732: Rename types.Union to types.UnionType (bpo-27342)
    2b8ad9e

    @miss-islington
    Copy link
    Contributor

    New changeset 8a37e8c by Miss Islington (bot) in branch '3.10':
    bpo-44732: Rename types.Union to types.UnionType (GH-27342)
    8a37e8c

    @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 interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants