Summary
Pylint is complaining of undefined variables in class declarations and the following functions. If I comment out the class declarations, the functions are still being highlighted and I am unsure why.
Environment
OS: Suse Leap 42.3
Editor: vscode 1.38
Python: 3.4.6
Pylint: 1.4.4
Pylint Args: ["--load-plugin", "pylint_protobuf", "--enable=F,E,W"]
Reproduction case
#!/usr/bin/env python3
'''Dummy doc string'''
from ctypes import * # pylint: disable=unused-wildcard-import
class BOX(Structure):
_fields_ = [("x", c_float),
("y", c_float),
("w", c_float),
("h", c_float)]
def example(a, b):
c = str(a + b)
print(c)
Which produces the following errors/warnings
Undefined variable 'Structure' pylint(undefined-variable) [6, 11]
Undefined variable 'a' pylint(undefined-variable) [13, 13]
Undefined variable 'b' pylint(undefined-variable) [13, 17]
Undefined variable 'c' pylint(undefined-variable) [14, 11]
Locally disabling unused-wildcard-import (W0614) pylint(locally-disabled) [4,1]
If I hover over Structure
I can see class PyCStructType()
, likewise if I hover over c
I can see c: str
, so the datatypes are known.
Questions
- Why does the above code produce pylint errors? (I expect to only see a warning for locally disabling unused wildcard imports)
- Is this issue specific to my environment? (older version of python, etc.)
N.b. I do not want to use # pylint: disable=undefined-variable