Skip to content

Rename types.Union to types.UnionType #88895

Description

@serhiy-storchaka
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']

    Activity

    1. serhiy-storchaka commented on Jul 24, 2021

      @serhiy-storchaka
      MemberAuthor

      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.

    2. AliyevH commented on Jul 24, 2021

      AliyevHmannequin
      Mannequin

      If nobody works on it i would like to fix it

    3. AliyevH commented on Jul 25, 2021

      AliyevHmannequin
      Mannequin

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

    4. pablogsal commented on Jul 25, 2021

      @pablogsal
      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.

    5. gvanrossum commented on Jul 25, 2021

      @gvanrossum
      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.

    6. JelleZijlstra commented on Jul 26, 2021

      @JelleZijlstra
      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.

    7. ambv commented on Jul 26, 2021

      @ambv
      Contributor

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

    8. miss-islington commented on Jul 26, 2021

      @miss-islington
      Contributor

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

    9. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of life3.11only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions