Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DOC: Fixes absent line numbers on link to classes decorated with set_module#28918

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

aureliobarbosa
Copy link
Contributor

PR#28645 was intended to fix issue#28629, which indicated that wrong links were appearing on documentation for classes decorated with set_module. A minor problem appeared on that fix, since line numbers were not assigned to the link on those decorated classes.

This PR fixes this problem by storing the original value of property__module__ of decorated classes (instead of capturing the property__file__ of the original module).

In my opinion the current approach is simpler.

@aureliobarbosa
Copy link
ContributorAuthor

@melissawm and@ngoldbaum

Would you mind reviewing a follow up from#28645?

fn = relpath(fn, start=dirname(numpy.__file__))
# This can be removed when removing the decorator set_module. Fix issue #28629
if hasattr(obj, '_module_source'):
obj = copy(obj)
Copy link
Member

Choose a reason for hiding this comment

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

this is a no-op:

>>>import copy>>>classA:...... >>> copy.copy(A)is ATrue

and it's the same story withcopy.deepcopy:

>>> copy.deepcopy(A)is ATrue

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks for pointing that, just got to realize that copy is a little bit subtle.

The intention of the copy was to not introducing any side effect, even while running on the documentation.
Now, the whole thing about changing__module__ is about its side effect and, as discussedpreviously it was needed downstream.

Since this code is running while generating the docs, do you think we could just recover the original__module__ without further problems?

Copy link
Member

Choose a reason for hiding this comment

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

Since this code is running while generating the docs, do you think we could just recover the original__module__ without further problems?

I guess that depends on whether the docs currently (also) use the patched__module__ somewhere, and if so, where/when that happens. Put differently; it shouldn't be a problem if it doesn't also change the documented module paths.

But I'm not very familiar with this doc generation code, so it's probably best if another maintainer could chime in here.

aureliobarbosa reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

As long as the docs build fine and there aren't any other regressions introduced it should be fine. You could try looking at a diff of the docs build before and after applying the change to see what changes.

It looks like there are some new warnings in the docs build - those need to be fixed too.

aureliobarbosa reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ok. I will take a look at this and give the feedback here.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@jorenham and@ngoldbaum.

This is ready for review.

@aureliobarbosaaureliobarbosa marked this pull request as draftMay 13, 2025 18:10
@aureliobarbosaaureliobarbosaforce-pushed thefix_classes_with_incorrect_line_numbers branch fromde6f864 to6ed0eceCompareMay 14, 2025 14:54
@aureliobarbosaaureliobarbosa marked this pull request as ready for reviewMay 14, 2025 15:23
Copy link
Member

@jorenhamjorenham left a comment

Choose a reason for hiding this comment

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

thepoly1d docs now indeed include line numbers in the source code link:

https://output.circle-artifacts.com/output/job/482f8884-cb97-4a2f-8430-7fd1c14dc47b/artifacts/0/doc/build/html/reference/generated/numpy.poly1d.html#numpy.poly1d

The line numbers are offset because this branch isn't up-to-date with main. Replacing the url and branch with this one, shows that the line numbers are indeed correct:https://github.com/aureliobarbosa/numpy/blob/fix_classes_with_incorrect_line_numbers/numpy/lib/_polynomial_impl.py#L1087-L1457

aureliobarbosa reacted with laugh emoji
@ngoldbaum
Copy link
Member

Thanks@aureliobarbosa! Sorry for taking a little while to get back to this.

@ngoldbaumngoldbaum merged commit2a7a0d0 intonumpy:mainMay 20, 2025
74 checks passed
@aureliobarbosa
Copy link
ContributorAuthor

Thanks@ngoldbaum

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jorenhamjorenhamjorenham approved these changes

@ngoldbaumngoldbaumAwaiting requested review from ngoldbaum

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@aureliobarbosa@ngoldbaum@jorenham

[8]ページ先頭

©2009-2025 Movatter.jp