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

Type (typing) objects are hashable and comparable for equality but this is not documented #71775

Closed
gareth-rees mannequin opened this issue Jul 22, 2016 · 3 comments
Closed
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@gareth-rees
Copy link
Mannequin

gareth-rees mannequin commented Jul 22, 2016

BPO 27588
Nosy @gvanrossum, @gareth-rees, @ilevkivskyi

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 2016-10-09.03:18:21.197>
created_at = <Date 2016-07-22.09:50:51.088>
labels = ['type-feature', 'docs']
title = 'Type (typing) objects are hashable and comparable for equality but this is not documented'
updated_at = <Date 2016-10-09.03:18:21.179>
user = 'https://github.com/gareth-rees'

bugs.python.org fields:

activity = <Date 2016-10-09.03:18:21.179>
actor = 'gvanrossum'
assignee = 'docs@python'
closed = True
closed_date = <Date 2016-10-09.03:18:21.197>
closer = 'gvanrossum'
components = ['Documentation']
creation = <Date 2016-07-22.09:50:51.088>
creator = 'gdr@garethrees.org'
dependencies = []
files = []
hgrepos = []
issue_num = 27588
keywords = []
message_count = 3.0
messages = ['270981', '270997', '278337']
nosy_count = 4.0
nosy_names = ['gvanrossum', 'docs@python', 'gdr@garethrees.org', 'levkivskyi']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue27588'
versions = ['Python 3.5', 'Python 3.6']

@gareth-rees
Copy link
Mannequin Author

gareth-rees mannequin commented Jul 22, 2016

The type objects constructed by the metaclasses in the typing module are hashable and comparable for equality:

    >>> from typing import *
    >>> {Mapping[str, int], Mapping[int, str]}
    {typing.Mapping[int, str], typing.Mapping[str, int]}
    >>> Union[str, int, float] == Union[float, int, str]
    True
    >>> List[int] == List[float]
    False

but this is not clearly documented in the documentation for the typing module (there are a handful of examples using equality, but it's not explicit that these are runnable).

It would be nice if there were explicit documentation for these properties of type objects.

@gareth-rees gareth-rees mannequin assigned docspython Jul 22, 2016
@gareth-rees gareth-rees mannequin added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Jul 22, 2016
@bitdancer bitdancer changed the title Type objects are hashable and comparable for equality but this is not documented Type (typing) objects are hashable and comparable for equality but this is not documented Jul 22, 2016
@ilevkivskyi
Copy link
Member

I am not sure that this feature will survive the resolution of python/typing#136

Types in typing are primarily intended for use with static type checkers and similar tools, their runtime properties are still under some discussions.

@gvanrossum
Copy link
Member

Fixed by the changes for issue bpo-28388.

@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
docs Documentation in the Doc dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants