Skip to content

False positive for constant naming style inside __main__ block #10766

@o-alquimista

Description

@o-alquimista

Bug description

In file __main__.py, I have this:

def main() -> int:
    # ...

if __name__ == '__main__':
    exit_code = main()
    raise SystemExit(exit_code)

Configuration

Not using a configuration file. All default options.

Command used

pylint basketcase.__main__

Pylint output

src/basketcase/__main__.py:385:4: C0103: Constant name "exit_code" doesn't conform to UPPER_CASE naming style (invalid-name)

Expected behavior

Pylint thinks exit_code should be named EXIT_CODE, as if it were a constant. The function main returns an integer that can currently be 1 (error) or 0 (no error).

Pylint version

pylint 4.0.4
astroid 4.0.2
Python 3.12.3 (main, Nov  6 2025, 13:44:16) [GCC 13.3.0]

OS / Environment

elementary OS 8 (based on Ubuntu 24.04).
VSCodium terminal, version 1.106.37943.

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: invalid-nameFalse Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions