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

GH-101100: Fix reference warnings for __getitem__ #110118

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

AA-Turner
Copy link
Member

@AA-Turner AA-Turner commented Sep 29, 2023

@AA-Turner AA-Turner added needs backport to 3.11 only security fixes needs backport to 3.12 bug and security fixes labels Sep 29, 2023
@AA-Turner AA-Turner requested review from rhettinger and a team as code owners September 29, 2023 18:16
@bedevere-app bedevere-app bot added awaiting review docs Documentation in the Doc dir skip news labels Sep 29, 2023
@AA-Turner AA-Turner removed request for a team and rhettinger September 29, 2023 18:16
@AA-Turner AA-Turner changed the title Fix reference warnings for __getitem__ GH-101100: Fix reference warnings for __getitem__ Sep 29, 2023
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, there was no need to add the object. prefix. All object methods were automatically found. I don't know why it broke and from where. If someone could fix this, it would save us from rewriting a lot of references.

@AA-Turner
Copy link
Member Author

AA-Turner commented Sep 30, 2023

Do you have a rough idea of when it was working? (2010? 2015? 2020?) I could look at this, but unbounded I fear it'd be a fairly time consuming activity.

Prepending references with ~object. is a fairly easy mechanical task, though I appreciate it adds noise. From what I understand of Sphinx though, it does seem the 'proper' thing to do.

Perhaps of interest, this is a table of the frequency of dunder attributes that cause reference warnings (I've filtered a little but not properly):

Count Type Target
32 meth __exit__
31 meth __getitem__
26 meth __enter__
21 meth __get__
21 meth __init__
20 meth __iter__
20 meth __getattr__
20 meth __new__
16 attr __doc__
15 meth __getattribute__
13 meth __repr__
12 attr __cause__
12 meth __set__
12 meth __contains__
11 attr __annotations__
11 meth __hash__
10 attr __module__
10 attr __context__
10 meth __eq__
10 meth __len__
10 attr __self__
8 meth __reduce__
7 meth __str__
7 meth __add__
7 attr __func__
6 attr __traceback__
6 meth __delete__
6 meth __reversed__
6 meth __dir__
6 meth __lt__
6 meth __await__
6 meth __setstate__
6 meth __missing__
6 meth __setitem__
6 meth __index__
5 meth __set_name__
5 meth __radd__
5 meth __getstate__
5 meth __cmp__
4 meth __call__
4 meth __le__
4 meth __ge__
4 meth __format__
4 meth __delitem__
4 meth __int__
3 attr __suppress_context__
3 attr __members__
3 meth __getnewargs__
3 attr __wrapped__
3 meth __gt__
3 meth __setattr__
3 meth __or__
3 attr __code__
3 meth __ne__
3 meth __truediv__
3 meth __unicode__
2 meth __reduce_ex__
2 attr __isabstractmethod__
2 meth __and__
2 attr __notes__
2 func __getattr__
2 attr __defaults__
2 attr __globals__
2 attr __closure__
2 attr __type_params__
2 meth __floordiv__
2 meth __iadd__
2 attr __methods__
2 meth __coerce__
2 meth __complex__
2 meth __hex__
2 meth __oct__
2 meth __matmul__
1 meth __next__
1 meth __subclasscheck__
1 meth __aenter__
1 meth __aexit__
1 meth __abs__
1 func __getattribute__
1 meth __getnewargs_ex__
1 meth __bytes__
1 meth __fspath__
1 attr __kwdefaults__
1 meth __pow__
1 meth __neg__
1 meth __pos__
1 meth __invert__
1 meth __mul__
1 meth __rmul__
1 meth __mod__
1 meth __sub__
1 meth __lshift__
1 meth __rshift__
1 meth __rand__
1 meth __xor__
1 meth __rxor__
1 meth __ror__
1 meth __isub__
1 attr __metaclass__
1 attr __class__
1 meth __sizeof__
1 data __metaclass__
1 meth __getslice__
1 meth __setslice__
1 meth __delslice__
1 func __repr__
1 func __str__
1 meth __del__
1 meth __rmatmul__
1 meth __imatmul__
1 meth __rmod__
1 meth __divmod__
1 meth __aiter__
1 attr __all__
1 meth __class_getitem__

A

@serhiy-storchaka
Copy link
Member

Perhaps it worked 10 years ago. There were more Python specific code in Doc/tools/extensions, and Sphinx itself was more Python-oriented. Or maybe it was just a legend, I don't remember.

@serhiy-storchaka
Copy link
Member

It perhaps worked by accident on old Sphinx versions.

@serhiy-storchaka
Copy link
Member

LGTM.

@AA-Turner, are you going to create a separate PR for every dunder method? Some lines contain references to several dunder methods (for example __getitem__, __iter__, __len__, __setitem__). The same line can be modified several times in a series of PRs. It will make reading history more difficult. Why not merge changes for several related methods in one PR?

@hugovk hugovk merged commit da99133 into python:main Oct 19, 2023
29 checks passed
@miss-islington-app
Copy link

Thanks @AA-Turner for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 19, 2023
…-110118)

(cherry picked from commit da99133)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 19, 2023
…-110118)

(cherry picked from commit da99133)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Oct 19, 2023

GH-111073 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Oct 19, 2023
@bedevere-app
Copy link

bedevere-app bot commented Oct 19, 2023

GH-111074 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Oct 19, 2023
hugovk pushed a commit that referenced this pull request Oct 19, 2023
…) (#111073)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
hugovk pushed a commit that referenced this pull request Oct 19, 2023
…) (#111074)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
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 skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants