GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-122102: Fix/improve docs of descriptor-related tools in `inspect` by zuo · Pull Request #122104 · python/cpython Conversation
|
|
Note: it may be worth to apply the documentation changes to all supported versions of Python (starting with 3.8). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If you want to emphasize the terms getset, you should do it for slot as well when talking about slot descriptors I think. Personally, I would simply consider getset as a common noun, so no need for having *getset* or *properties* as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Does this rule apply also to documentation-only changes? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
OK, you convinced me. :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
AFAIK, yes. @hugovk Do you confirm? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
8ee1d5a to
2a11629
Compare
inspectinspect.is{data,method}descriptor()
inspect.is{data,method}descriptor()inspect
inspectinspect
There was an error while loading. Please reload this page.
|
I decided to exclude the tests-related changes from this PR, and create a separate PR that includes them. Rationale: those two sets of changes may be desired to be backported to different sets of Python versions, as:
I am very sorry for the fuss with all this PR splitting (I should have thought about it earlier...). :-| |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Method descriptors that also pass any of the other tests mentioned above | ||
| (:func:`isclass`, :func:`ismethod` or :func:`isfunction`) make this function |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's a bit weird to say "mentioned above" and re-mention them. Either you mention them again (which I wouldn't suggest) or you just say "mentioned above".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| descriptors and member descriptors. Note that for the latter two (which can | ||
| be defined only at the C level, in extension modules) more specific tests | ||
| are available: :func:`isgetsetdescriptor` and :func:`ismemberdescriptor`, | ||
| respectively. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| descriptors and member descriptors. Note that for the latter two (which can | |
| be defined only at the C level, in extension modules) more specific tests | |
| are available: :func:`isgetsetdescriptor` and :func:`ismemberdescriptor`, | |
| respectively. | |
| descriptors and member descriptors. Note that specific tests robust | |
| across different Python implementations are available for the latter | |
| two (defined in C extension modules), namely :func:`isgetsetdescriptor` | |
| and :func:`ismemberdescriptor` respectively. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I find the fragment about those two specific tests being robust across different Python implementations quite problematic: in a way, those two tests can be considered less robust across different Python implementations. (If I needed a test returning true for, e.g., a frame's f_locals regardless of the Python implementation being used, I'd use isdatadescriptor() rather than isgetsetdescriptor()...).
That's why I propose to remove that fragment.
IMHO, it causes more confusion than good.
Also I believe that the statement that those two tests are more specific, together with the docs of those two tests themselves, convey enough information.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Typically, data descriptors have also :attr:`~definition.__name__` and | ||
| :attr:`!__doc__` attributes (properties, getsets and member descriptors have | ||
| them), but this is not guaranteed. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| Typically, data descriptors have also :attr:`~definition.__name__` and | |
| :attr:`!__doc__` attributes (properties, getsets and member descriptors have | |
| them), but this is not guaranteed. | |
| While data descriptors such as properties, getsets or member descriptors | |
| have :attr:`~definition.__name__` and :attr:`!__doc__` attributes, this | |
| is not necessarily the case in general. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I believe that the fragment referring to properties, getsets or member descriptors should remain in parentheses, as it conveys here only additional (extra) information, not the crucial one (which is that, in general, the presence of the data descriptors' attributes __name__ and __doc__ is likely but optional).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Bénédikt Tran <[email protected]>
…2102.Za48MH.rst Co-authored-by: Bénédikt Tran <[email protected]>
(further edits of docstrings)
|
Sorry, I just learned that docs-only changes should not be announced in NEWS. So I delete the blurb. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Bénédikt Tran <[email protected]>
There was an error while loading. Please reload this page.
Documentation build overview
6 files changed ·
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
| Return ``True`` if the object is a method descriptor, but not if | ||
| :func:`ismethod`, :func:`isclass`, :func:`isfunction` or :func:`isbuiltin` | ||
| are true. | ||
| :func:`isclass`, :func:`ismethod` or :func:`isfunction` are true. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think it should be is true
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think we're probably due to update away from the "new in Python 2.2" note :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| the other tests promise more -- you can, e.g., count on having the | ||
| __func__ attribute (etc) when an object passes ismethod().""" | ||
| tests (ismethod(), isclass(), isfunction()) make this function return | ||
| false, simply because those other tests promise more -- you can, e.g., |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We're generally moving away from latin abbreviations like e.g.; it can be expanded to "for example".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the patch! This will merge after CI passes. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
GH-153948 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-153949 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-153950 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.