I would like to configure VSCode in such a way that I can see red squiggly lines when there is an error in my python code.
My VSCode currently shows me Python syntax errors (e.g. pri nt("hello") will have a red squiggly line), but not the following errors:
class Dog:
attr1 = "mammal"
attr2 = "dog"
def fun(self):
print("I'm a", self.attr1)
print("I'm a", self.attr3)
Rodger = Dog()
print(Rodger.attr1)
Rodger.bark()
In the code above I would like to see a red squiggly line on print("I'm a", self.attr3) since this object doesn't have a self.attr3 attribute, and Rodger.bark() since this object doesn't have a bark method.
You will need linters like Pylint which is supported by vscode. From the docs:
linting detects use of an uninitialized or undefined variable, calls to undefined functions, missing parentheses, and even more subtle issues such as attempting to redefine built-in types or functions.
After that you will need to turn on strict mode. Here is the link on how to do that. Microsoft explains it better than I can do on how to set it up.
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