I noticed this strange behavior when using debug to debug some if-else blocks in my code. Here is a small script to recreate the bug.
# script.py
from devtools import debug
class Test:
def __init__(self, flag: bool):
if flag:
debug('Flag was true')
else:
debug('Flag was false')
# instantiate this class with True flag
test = Test(flag=True)
Output of python script.py:
script.py:7 __init__ (error parsing code, IndentationError: unindent does not match any outer indentation level (script.py, line 3))
'Flag was true' (str) len=13
There is no indentation error in the code, and furthermore, I notice that adding something benign after the debug statement makes this go away. For example, if instead script.py looks like this, there is no issue:
# script2.py
from devtools import debug
class Test:
def __init__(self, flag):
if flag:
debug('Flag was true')
print('This helps debug out for some reason.')
else:
debug('Flag was false')
test = Test(True)
Output of python script2.py (which I expect to happen normally):
script2.py:7 __init__
'Flag was true' (str) len=13
This helps debug out for some reason.
Environment info: I tested this by creating a new conda environment with python 3.7.
I noticed this strange behavior when using
debug
to debug some if-else blocks in my code. Here is a small script to recreate the bug.Output of
python script.py
:There is no indentation error in the code, and furthermore, I notice that adding something benign after the debug statement makes this go away. For example, if instead
script.py
looks like this, there is no issue:Output of
python script2.py
(which I expect to happen normally):Environment info: I tested this by creating a new conda environment with python 3.7.