Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Constant name doesn't conform' warning on global statement instead of declaration #8307

Closed
macdjord opened this issue Feb 16, 2023 · 0 comments · Fixed by #8337
Closed

'Constant name doesn't conform' warning on global statement instead of declaration #8307

macdjord opened this issue Feb 16, 2023 · 0 comments · Fixed by #8337
Assignees
Labels
Bug 🪲 Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@macdjord
Copy link

macdjord commented Feb 16, 2023

Bug description

import typing as _tp

_foo: _tp.Optional["Foo"] = None


class Foo:
    ...


def setup_shared_foo():
    global _foo

    _foo = Foo()

Configuration

No response

Command used

pylint test.py

Pylint output

test.py:11:4: C0103: Constant name "_foo" doesn't conform to UPPER_CASE naming style ('([^\\W\\da-z][^\\Wa-z]*|__.*__)$' pattern) (invalid-name)

Expected behavior

Pylint should warn about the 'incorrect' variable name on line 3, where the variable is defined, not line 11, where it is used in a global statement.

Pylint version

pylint 2.16.2
astroid 2.14.2
Python 3.11.2 (tags/v3.11.2:878ead1, Feb  7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)]

OS / Environment

Windows 10

Additional dependencies

No response

@macdjord macdjord added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Feb 16, 2023
@mbyrnepr2 mbyrnepr2 added Bug 🪲 Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Feb 17, 2023
@mbyrnepr2 mbyrnepr2 self-assigned this Feb 24, 2023
mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Feb 24, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.3 milestone Feb 24, 2023
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Feb 27, 2023
…v#8337)

Closes pylint-dev#8307

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Pierre-Sassoulas added a commit that referenced this issue Feb 27, 2023
…8354)

Closes #8307

Co-authored-by: Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants