-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
bpo-40304: Correct type(name, bases, dict) doc #19553
Conversation
Please correct me if there's some gotcha I'm missing, but if classes inherit from >>> type('X', (object,), dict(a=1)).__bases__
(<class 'object'>,)
>>> type('X', (), dict(a=1)).__bases__
(<class 'object'>,) |
object
base class from type
docsobject
base class from type
docs
No gotcha, in Python 3 both are equivalent. This means that this bit of the docs (a couple paragraphs before your change) is not strictly accurate:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E'ric, can you finish this off, with blurb and possible additional doc change?
Ping, @merwok? |
Hi! I will come back to this. |
object
base class from type
docs
@taleinat @terryjreedy Please review additional changes!
|
I have added the skip news and backport labels. If there is no negative review about the wording I will merge this in a couple days! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an important fix and I like the direction!
However, the new wording is still not accurate: When providing one or more base classes, object
is not added to __bases__
. For example:
>>> class A:
pass
>>> type('B', (A,), {}).__bases__
(<class '__main__.A'>,)
Also, if the attributes dict doesn't become __dict__
, what exactly is done with it? Perhaps this would be a good place for a link to the docs about class instantiation?
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
It is passed to the metaclass so that functions become methods, other descriptors do their thing, and all attributes are stored in the class object in the end… in |
Text I removed:
so it was not wrong but could be confusing; what do you think about this change:
(let me check if the link target only talks about class instances) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Small suggestion about the NEWS entry, @terryjreedy.
Misc/NEWS.d/next/Documentation/2021-01-20-23-03-49.bpo-40304.-LK7Ps.rst
Outdated
Show resolved
Hide resolved
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be put in the comfy chair! |
Co-authored-by: Tal Einat <[email protected]>
…LK7Ps.rst Co-authored-by: Tal Einat <[email protected]>
Doc/library/functions.rst
Outdated
:attr:`~class.__bases__` attribute; if empty, :class:`object`, the | ||
ultimate base of all classes, is added. The *dict* dictionary contains | ||
attribute and method definitions for the class body; it may be copied | ||
or wrapped before becoming the :attr:`~class.__dict__` attribute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this link go?
class.__bases__
is at https://docs.python.org/3/library/stdtypes.html#class.__bases__
does class.__dict__
go to https://docs.python.org/3/reference/datamodel.html#index-48 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No link is created!
Ideas:
- keep
object.__dict__
but amend the doc there (in library/stdtypes) to describe__dict__
for class objects - change the reference to be to
__dict__ (class attribute)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I changed object
to class
and that does not work, I changed it back for this issue, so it continues to link to
file:///F:/dev/3x/Doc/build/html/library/stdtypes.html#object.dict
Since 'objects' include 'classes', the current text is not incorrect. I consider changing it a separate issue.
If classes were the only objects with dict attribute (I am not sure), and object.dict should be class.dict, a change would require grepping for other references to change. This would be a different issue also.
Thanks @verhovsky for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
Co-authored-by: Éric Araujo <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]> Co-authored-by: Tal Einat <[email protected]> (cherry picked from commit 644d528) Co-authored-by: Борис Верховский <[email protected]>
GH-24295 is a backport of this pull request to the 3.9 branch. |
Co-authored-by: Éric Araujo <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]> Co-authored-by: Tal Einat <[email protected]> (cherry picked from commit 644d528) Co-authored-by: Борис Верховский <[email protected]>
GH-24296 is a backport of this pull request to the 3.8 branch. |
Co-authored-by: Éric Araujo <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]> Co-authored-by: Tal Einat <[email protected]> (cherry picked from commit 644d528) Co-authored-by: Борис Верховский <[email protected]>
Boris, you have 6 merged PRs before this. After checking them, I think you qualify for a listing in Misc/acks. If you make a PR with no issue or news to add yourself, with the improved English transliteration, and request my review, I will merge it, and ask for a 3.9 backport. |
Co-authored-by: Éric Araujo <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]> Co-authored-by: Tal Einat <[email protected]> (cherry picked from commit 644d528) Co-authored-by: Борис Верховский <[email protected]>
Co-authored-by: Éric Araujo <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]> Co-authored-by: Tal Einat <[email protected]>
https://bugs.python.org/issue40304