Skip to content

Module and class resolver #24

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

Closed
wants to merge 5 commits into from
Closed

Conversation

erlend-aasland
Copy link

@erlend-aasland erlend-aasland commented Aug 17, 2023

Experimenting with variants of this resolver.

@erlend-aasland erlend-aasland marked this pull request as draft August 17, 2023 22:16
Copy link

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks, this is a big readability improvement!

Comment on lines +2422 to +2423
module = parent.modules[field]
parent = module

Choose a reason for hiding this comment

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

I actually find putting both assignments on one line more readable -- conceptually, you're assigning both variables to the same thing here (parent.modules[field]), rather than assigning module to parent.modules[field], and then assigning module to whatever parent is:

Suggested change
module = parent.modules[field]
parent = module
parent = module = parent.modules[field]

Comment on lines +2426 to +2427
cls = parent.classes[field]
parent = cls

Choose a reason for hiding this comment

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

Same here, I actually find it more readable to have them both on one line:

Suggested change
cls = parent.classes[field]
parent = cls
parent = cls = parent.classes[field]

cls = parent.classes[field]
parent = cls
else:
fullname = ".".join(fields[idx])

Choose a reason for hiding this comment

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

I. .t.h.i.n.k. .t.h.i.s. .i.s. .g.o.i.n.g. .t.o. .p.r.o.d.u.c.e. .o.u.t.p.u.t. .l.i.k.e. .t.h.i.s

Choose a reason for hiding this comment

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

>>> fields = ["foo", "bar"]
>>> idx = 1
>>> ".".join(fields[idx])
'b.a.r'

Copy link
Author

Choose a reason for hiding this comment

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

😂 There was supposed to be a : somewhere there

@erlend-aasland
Copy link
Author

Shall we upstream this? 😃

@AlexWaygood
Copy link

Shall we upstream this? 😃

I vote yes! We might want to add a regression test for https://github.com/Argument-Clinic/cpython/pull/24/files#r1298346341, though :)

@erlend-aasland
Copy link
Author

Shall we upstream this? 😃

I vote yes! We might want to add a regression test for https://github.com/Argument-Clinic/cpython/pull/24/files#r1298346341, though :)

Absolutely; I'll do that first :)

@erlend-aasland
Copy link
Author

Upstreamed at python#108552

@AlexWaygood AlexWaygood deleted the clinic/module-and-cls branch August 27, 2023 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants