Skip to content

enum.Enum type is blindly assigned to "Enum" of other modules #5719

@belm0

Description

@belm0

Bug description

For example, the prometheus_client module has an Enum class. Pylint blindly assumes that references to prometheus_client.Enum are of type enum.Enum, and issues incorrect warnings.

import prometheus_client

_foo_metric = prometheus_client.Enum('foo', 'help text', states=['bar', 'baz'])
_foo_metric.state('bar')  # pylint warning: Instance of 'foo' has no 'state' member

Command used

pylint test.py

Pylint output

************* Module test
test.py:4:0: E1101: Instance of 'foo' has no 'state' member (no-member)

Expected behavior

no warnings

Pylint version

pylint 2.12.1
astroid 2.9.0
Python 3.8.12 (default, Sep 23 2021, 08:42:37)
[Clang 12.0.0 (clang-1200.0.32.29)]

Additional dependencies

prometheus_client==0.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeLib specific 💅This affect the code from a particular libraryNeeds astroid updateNeeds an astroid update (probably a release too) before being mergableNeeds investigation 🔬A bug or crash where it's not immediately obvious what is happenninginference

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions