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

More accurate function definition lineno #124

Open
laike9m opened this issue May 12, 2021 · 2 comments
Open

More accurate function definition lineno #124

laike9m opened this issue May 12, 2021 · 2 comments
Labels
bug Something isn't working good-first-issue Issues that are good for first time contributors p1

Comments

@laike9m
Copy link
Owner

laike9m commented May 12, 2021

Now frame.defined_lineno is the line of the first decorator. Ideally it should be the line where def is at.

image

@laike9m laike9m added bug Something isn't working p1 labels May 12, 2021
@laike9m laike9m added the good-first-issue Issues that are good for first time contributors label May 12, 2021
@victorjzsun
Copy link
Collaborator

I'm not sure if this is possible without analyzing source code. Since there is nothing actually happening on the def line, it is omitted in the bytecode. You also cannot use a previous or next line in the bytecode and then just add/subtract a line since comments can exist between decorators, def line, and function body which are also omitted in the bytecode

@laike9m
Copy link
Owner Author

laike9m commented May 18, 2021

Comments between decorators should be very rare. For the normal cases, potentially we can imitate what the undecorated lib is doing and count the number of decorators, then add the number of lines:

https://github.com/iartarisi/undecorated/blob/master/undecorated.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good-first-issue Issues that are good for first time contributors p1
Projects
None yet
Development

No branches or pull requests

2 participants