I have this piece of code in a Python module open in PyCharm Community Edition 2017.2.
class Sample(object):
def __init__(self):
self.prop1 = 5
self.prop2 = 10
def method1(self):
return foo
def do_work(self):
not_defined_func()
s = Sample()
s.method1()
bar = call_func
The IDE doesn't give any warnings on some fairly serious issues:
foo
has not been defined.call_func
to the variable bar
.not_defined_func
inside the method do_work
. How do I enable PyCharm to highlight these things? I have a fresh installation of PyCharm and have all the Inspections
enabled in File > Settings > Editor > Inspections > Python
.
There are a few ways to fix an undefined variable: (1) You can rename the variable or variable set so that it matches what you have used in the topic; (2) you can re-insert the variable in the topic so that it uses an existing variable set/variable name, (3) you can add the undefined variable to the project as a new ...
This error means that within your code, there is a variable or constant which is not set. But you may be trying to use that variable. The error can be avoided by using the isset() function.
See which python interpreter is enabled go to preference > Project > Project Interpreter. Set python interpreter and then apply it. Also check if inspections are enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With