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

[Bug] import statement in method: 'error parsing code, unable to find "debug" function statement' #84

Closed
Jasha10 opened this issue Jun 23, 2021 · 5 comments

Comments

@Jasha10
Copy link

Jasha10 commented Jun 23, 2021

Bug

When the from devtools import debug statement occurs within a method (as opposed to at toplevel of the module), an "error parsing code" message is printed.

Min repro:

The following works as expected:

# tmp.py
from devtools import debug
def foo():
    debug(123)
foo()
$ python tmp.py
tmp.py:4 foo
    123 (int)

But if you put the import statement inside the method, there is an error:

# tmp2.py
def foo():
    from devtools import debug
    debug(123)
foo()
$ python tmp2.py
tmp2.py:4 foo (error parsing code, unable to find "debug" function statement)
    123 (int)
@Jasha10
Copy link
Author

Jasha10 commented Jun 23, 2021

Version info:

$ pip list | grep devt
devtools                      0.6.1
$ python --version
Python 3.9.5

@samuelcolvin
Copy link
Owner

ye, to find the text inside the parentheses debug('this bit'), devtools has to search the string from the line where debug() is called.

That means sometimes it finds the wrong reference to debug(). If you can find a fix, happy to accept, but I don't have time to work on this right now.

@alexmojaki
Copy link
Contributor

This is fixed in #82

@samuelcolvin
Copy link
Owner

Good point, I had a vague memory that this should be fixed. I'll look at that soon.

@samuelcolvin
Copy link
Owner

fixed by #82

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

No branches or pull requests

3 participants