| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
In Lib/test/test_inspect/inspect_fodder.py, the last class has a bunch of comments where the comment includes the specific line number, i.e. # line 95 is line 95 of the original file. The updates in this PR include adding lines to that file and so those comments are no longer on the lines that they reference. I'm having trouble getting the test suite working locally to get a sense of if that matters at all, but I'm guessing that some inspect tests may be looking at those comments for some reason or another? |
Sorry, something went wrong.
I believe I fully reverted that in my later commits. There should no longer be any changes to inspect_fodder.py. Which commit have you pulled? Those comments are there to test the comment extractor part of inspect.py. After a bit of testing I felt adding new stuff to the fodder file required changing more hard coded numbers than I thought was worthwhile, so I made a new fodder file. I'm also having trouble getting the test suite working after my last pull from main. Are you getting the same "cannot import name 'Union' from '_typing' (unknown location)" error? |
Sorry, something went wrong.
|
ope, my bad, was looking at a commit and spent so long trying to get the devcontainer to work you had made new updates since then that I didn't look at. |
Sorry, something went wrong.
There was a problem hiding this comment.
can you please check the failing tests here please, Tests / Hypothesis tests on Ubuntu (pull_request) ? if they are relevant failures?
Sorry, something went wrong.
Syncing with main this afternoon seems to have fixed it. I'm not sure why it was failing in the first place, since it seems to test code that I didn't modify at all. The tests ran fine on my Ubuntu terminal before and after I submitted so that was a bit baffling to me. |
Sorry, something went wrong.
|
The test is flaky I think (we've seen similar failures elsewhere) |
Sorry, something went wrong.
|
@picnixz Do you have any thoughts on this pr? It's been a couple weeks and I'm hoping for core dev to look at it. |
Sorry, something went wrong.
|
I don't have time until the end of the week so I'm requesting myself a review |
Sorry, something went wrong.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
| def foo(self): | ||
| pass | ||
|
|
||
| # Redine foo as something other than cached_property |
There was a problem hiding this comment.
| # Redine foo as something other than cached_property | |
| # redefine foo as something other than cached_property |
Sorry, something went wrong.
There was a problem hiding this comment.
Just some cosmetic nits.
@serhiy-storchaka is there something we need to be careful about here?
Sorry, something went wrong.
Sorry, something went wrong.
|
I haven't looked at this PR yet, but note that there is a duplicate of this function in the pydoc module. |
Sorry, something went wrong.
Good to know then. @lincolnj1 can you check also the pydoc module please? |
Sorry, something went wrong.
There was a problem hiding this comment.
It seems to me that you went overboard with the tests (the simplest test would have been enough), but overall LGTM.
Sorry, something went wrong.
This is a trauma I had from maintaining Sphinx. There were so many edge cases because of inheritance. It also serves as a robust way to detect future possible regressions (but I agree that it's a bit of an overkill). |
Sorry, something went wrong.
Yes, it seems that one is also broken in the same way (see below). I'll take a look at fixing it. Should I open a new PR to fix that or keep working in this one? Edit: I used the private _getdoc method here when I should've used the public getdoc, but the behavior is consistent using either method. >>> import pydoc
>>> import inspect
>>> pydoc._getdoc(int)
"int([x]) -> integer\nint(x, base=10) -> integer\n\nConvert a number or string to an integer, or return 0 if no arguments\nare given. If x is a number, return x.__int__(). For floating-point\nnumbers, this truncates towards zero.\n\nIf x is not a number or if base is given, then x must be a string,\nbytes, or bytearray instance representing an integer literal in the\ngiven base. The literal can be preceded by '+' or '-' and be surrounded\nby whitespace. The base defaults to 10. Valid bases are 0 and 2-36.\nBase 0 means to interpret the base from the string as an integer literal.\n>>> int('0b100', base=0)\n4"
>>> inspect.getdoc(int)
"int([x]) -> integer\nint(x, base=10) -> integer\n\nConvert a number or string to an integer, or return 0 if no arguments\nare given. If x is a number, return x.__int__(). For floating-point\nnumbers, this truncates towards zero.\n\nIf x is not a number or if base is given, then x must be a string,\nbytes, or bytearray instance representing an integer literal in the\ngiven base. The literal can be preceded by '+' or '-' and be surrounded\nby whitespace. The base defaults to 10. Valid bases are 0 and 2-36.\nBase 0 means to interpret the base from the string as an integer literal.\n>>> int('0b100', base=0)\n4"
>>> inspect.getdoc(int) == pydoc._getdoc(int)
True
>>>
>>> from functools import cached_property
>>> class A:
... @cached_property
... def foo(self):
... "this is the docstring for foo"
... return 1
...
>>> class B(A):
... @cached_property
... def foo(self): ...
...
>>> pydoc._getdoc(B.foo)
>>> pydoc._getdoc(A.foo)
'this is the docstring for foo'
>>> pydoc._getdoc(B.foo) == pydoc._getdoc(A.foo)
False
>>>
>>>
>>>
>>> class MethodBase:
... def foo(self):
... "my method foo"
...
>>> class Child(MethodBase):
... def foo(self): ...
...
>>> pydoc._getdoc(MethodBase.foo) == pydoc._getdoc(Child.foo) #method docstrings are inherited properly!
True |
Sorry, something went wrong.
|
If there are plans to backport this change, you need to fix the pydoc version too (it is just a copy). Otherwise, you may wait until #132686 has been resolved. |
Sorry, something went wrong.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Calling inspect.getdoc on a cached_property that inherits a docstring and does not define one would return None rather than the inherited docstring. This is because inspect._finddoc would treat the cached_property obj as a methoddescriptor and encounter an AttributeError trying to access obj.__name__. This PR adds a special case for cached_properties in _finddoc so that it can find the inherited docstring.