1

When I run pylint on a code like this one:

some_variable = 3

def do_something():
    pass


if __name__ == '__main__':
    do_something()

I get:

file.py:2:0: C0103: Constant name "some_variable" doesn't conform to UPPER_CASE naming style (invalid-name)

However, if I use typing to specify the type of the variable:

some_variable: int = 3

The invalid-name is not triggered anymore. Furthermore, I can use any name, like SOMEVARIABLE, someVariable or SOME_VARIABLE and it won't be triggered.

Why does this happen?

martineau
  • 119,623
  • 25
  • 170
  • 301
epalto
  • 11
  • 1
  • 1
    If you believe this is a bug, feel free to open an issue on their open-source project: https://github.com/PyCQA/pylint – zr0gravity7 Jul 09 '20 at 17:08

1 Answers1

-1

the variables that are not contained in a class or a function are expected to be constants and need to be in upper case. check here PEP 8 https://www.python.org/dev/peps/pep-0008/#naming-conventions

  • may have been answered here some years back – Bhaskar Tallamraju Jul 09 '20 at 17:37
  • Doesn't seem to answer the question. This answer confirms that a linting message should be triggered. But the question mentions clearly that, when there is a type annotation, no message is triggered. – sinoroc Jul 09 '20 at 18:37