pylint icon indicating copy to clipboard operation
pylint copied to clipboard

pylint fails to see that a module has no attribute by this name

Open omarandlorraine opened this issue 3 years ago • 0 comments

Bug description

Here are the contents of __main__.py:

#!/usr/bin/python

""" The program's entry point """

import sys
import i2c


if __name__ == '__main__':
    if "-f" in sys.argv:
        pic = i2c.PicComms(i2c.HardCoded())
    else:
        pic = i2c.PicComms()

Here are the contents of i2c.py

from datetime import datetime
import smbus

class PicComms:

    def __init__(self, fixture=None):
        self.bus = fixture or smbus.SMBus(11)  # pylint: disable=I1101

    @property
    def date(self):
        return self.bus.get_date()

There's an error in main.py because line 8 says i2c.HardCoded(), but the i2c module has no class by that name.

Configuration

No response

Command used

pylint -E *.py

Pylint output

(nothing)

Expected behavior

I would have expected pylint to output E1101: Module 'i2c' has no 'HardCoded' member (no-member) or some such

Pylint version

pylint 2.14.5
astroid 2.11.7
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]

OS / Environment

Debian 11.4

Additional dependencies

No response

omarandlorraine avatar Aug 10 '22 12:08 omarandlorraine