-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Add .end_lineno attribute to pyclbr _Objects #82488
Comments
Currently, the |
What 3.6 is in feature-freeze. The earliest that any enhancement could be added is version 3.9. Can you explain how having an ending line number as well as the starting line number can be used to check which imports are used in a class? |
How do I generate the endline no? Initially, I could |
I have made the changes and tested, my builds were successful. Please review it? CC @brandtbucher, @steven.daprano |
The answer, Aviral discovered, is that current ast nodes have end_lineno attributes, so the patch amounts to consistently copying them. I don't understand Aviral's use case either, but an item on my IDLE wish list is to be able to move class and function definitions within a file by moving the Class and Function entries within the browser tree. This requieres end lines and having it be an attribute is easier and more accurate than recalculating it. Merely clicking on an entry could highlight the whole definition. Other people might think of other uses. An issue in the patch is inserting parameter 'end_line' after 'line'. Normally, new parameters have to go at the end, but:
I posted "What is the pyclbr public API" to pydev asking about this issue. |
Hey Terry, thanks for commenting. I have a few questions to ask you, please pardon my lack of awareness.
How do you recalculate the end_lineno? Since all the objects that start, have an end too, would I could not make anything out of your third point where you mention
Can you share the link of your post? As for my use case, I need the scope of a class and a function in the new tool that I am developing. My tool is to generate a new type of UML diagrams for a given codebase. Do check it out and leave your critical feedback: https://github.com/kebab-mai-haddi/gruml I need to know about the scope (start and end) so that I can deduce whether the "used_at" attribute of an object is within a class. This will help me deduce whether a particular class (or a function) uses any imported object. This is to deduce the dependency of a class on other classes and functions. Currently, I have to edit the pyclbr and make it custom, then, had to Dockerize the whole thing. So, want to contribute to |
If IDLE were to recalculate the end from start, it would have to more or less parse forward to find the end of the statement. This is why I considered it a speculative wish.
Point 3: The existing doc implies but does not exactly state that the _Object signature are private, so that we could break any possibly existing (but possibly not, and discouraged) use. I think back-compatibility is discussed in the devguide. Posts do not have a link until distributed, and then you can find it on mail.python.org. The title is sufficient to do that. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: