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

issubclass doc improvement #60641

Closed
fossilet mannequin opened this issue Nov 8, 2012 · 6 comments
Closed

issubclass doc improvement #60641

fossilet mannequin opened this issue Nov 8, 2012 · 6 comments
Labels
3.11 only security fixes docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@fossilet
Copy link
Mannequin

fossilet mannequin commented Nov 8, 2012

BPO 16437
Nosy @ezio-melotti, @iritkatriel, @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 2012-11-08.14:04:40.938>
labels = ['3.11', 'type-feature', 'docs']
title = 'issubclass doc improvement'
updated_at = <Date 2021-06-17.08:36:23.012>
user = 'https://bugs.python.org/fossilet'

bugs.python.org fields:

activity = <Date 2021-06-17.08:36:23.012>
actor = 'iritkatriel'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2012-11-08.14:04:40.938>
creator = 'fossilet'
dependencies = []
files = []
hgrepos = []
issue_num = 16437
keywords = []
message_count = 5.0
messages = ['175158', '175208', '395921', '395942', '395979']
nosy_count = 5.0
nosy_names = ['fossilet', 'ezio.melotti', 'docs@python', 'iritkatriel', 'kj']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue16437'
versions = ['Python 3.11']

@fossilet
Copy link
Mannequin Author

fossilet mannequin commented Nov 8, 2012

http://docs.python.org/3/library/functions.html#issubclass

"classinfo may be a tuple of class objects."

I suggest make it clear like isinstance, use something like this:

classinfo may be a tuple of class objects and such tuples.

@fossilet fossilet mannequin assigned docspython Nov 8, 2012
@fossilet fossilet mannequin added the docs Documentation in the Doc dir label Nov 8, 2012
@ezio-melotti
Copy link
Member

While this is documented for isinstance, I'm not sure it should be advertised too much, as it seems to me an implementation detail and doesn't seem too useful in practice.

This is a side-effect of the fact that
isinstance(x, (A, B, ...))
is equivalent to
isinstance(x, A) or isinstance(x, B) or ...
and therefore
isinstance(x, (A, (B, C)))
is equivalent to
isinstance(x, A) or isinstance(x, (B, C))
which in turn is equivalent to
isinstance(x, A) or (isinstance(x, B) or isinstance(x, C))

While this behavior seems intentional 0, it doesn't seem to be tested 1. FTR this is supported by PyPy too.

@ezio-melotti ezio-melotti added the type-feature A feature request or enhancement label Nov 8, 2012
@iritkatriel
Copy link
Member

Whether the recursive nature of the check should be documented or not, it seems inconsistent that it's documented for isinstance but not for issubclass.

@iritkatriel iritkatriel added the 3.11 only security fixes label Jun 16, 2021
@Fidget-Spinner
Copy link
Member

@Irit, you may be interested in bpo-44135, there's an open PR there and it seems to fix what this issue describes.

@iritkatriel
Copy link
Member

@ken - not quite. This issue is about isinstance containing "(or recursively, other such tuples)" which is not there for issubclass.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@slateny
Copy link
Contributor

slateny commented Jun 3, 2022

This was made consistent by #92087 - if the recursive wording shouldn't be there for both funcs, then I think a new issue could be opened to discuss that instead of here.

@slateny slateny closed this as completed Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes docs Documentation in the Doc dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants