0

I'm attempting to use the OpenCv library, but I got the error that there was no library installed when it was installed. I fixed that issue by putting "python.linting.pylintArgs": ["--extension-pkg-whitelist=cv2"on my settings. However, now I get a warning when using a variable. The warning displayed is Constant name "img" doesn't conform to UPPER_CASE naming stylepylint(invalid-name) I'm using VS Code on MacOSX.

If I delete what I added to my settings the warnings go away, but doing so stops me from being able to use OpenCv.

img = cv2.imread('image.jpg', 0)

The expected results would just be code without any warnings

L.Ruiz
  • 13
  • 1
  • 7

4 Answers4

2

To disable this error system-wide, you'll need to add this to your VS Code settings (...'s represent already existing stuff, unneeded if doesn't exist):

"python.linting.pylintArgs": [..."disable=C0103"...]
1

Because of Python's PEP rules, you must use capital letters in variable names. Like a IMG = cv2.imread('image.jpg', 0)

  • 3
    "Function names should be lowercase, with words separated by underscores as necessary to improve readability. Variable names follow the same convention as function names." -- https://www.python.org/dev/peps/pep-0008/#function-and-variable-names So, no, the problem is that PyLint considers the variable a constant, which I would say is due to the lack of another assignment, but I have the same problem with a variable assigned more than once in the same scope. – gherson Oct 08 '21 at 19:55
1

Include comment

# pylint: disable=C0103

in your code file (per How do I tell PyLint "it's a variable, not a constant" to stop message C0103?).

(No word yet on how to disable that error message system-wide.)

gherson
  • 169
  • 2
  • 9
1

Yo can create a .pylintrc file on the root of your project so you can ignore the rule:

[MASTER]
disable=
    C0103, # uppercase naming style
    CXXXX, # add ad many as you need
Mr. MZ
  • 66
  • 2