pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.32k stars 1.14k forks source link

False positive no-member on http.HTTPStatus #8859

Open Gidgidonihah opened 1 year ago

Gidgidonihah commented 1 year ago

Bug description

As of python 3.9, IM_A_TEAPOT was added to http.HTTPStatus, but pylint reports a no-member error.

Can be replicated using the following code in example.py

"""Demonstrate a False positive with pylint."""

from http import HTTPStatus

print(HTTPStatus.IM_A_TEAPOT.value)
print(HTTPStatus.OK.value)

Configuration

Default configuration is used.

Command used

pylint example.py

Pylint output

************* Module pylint
/tmp/example.py:6:6: E1101: Class 'HTTPStatus' has no 'IM_A_TEAPOT' member (no-member)

-----------------------------------
Your code has been rated at 0.00/10

Expected behavior

No errors should be found.

Pylint version

All (current) versions after IM_A_TEAPOT was added are affected:

## Python 3.9

pylint 2.17.4
astroid 2.15.6
Python 3.9.17 (main, Jul  4 2023, 06:18:56)
[GCC 12.2.0]

## Python 3.10

pylint 2.17.4
astroid 2.15.6
Python 3.10.11 (main, Apr  5 2023, 23:35:11) [GCC 10.2.1 20210110]

## Python 3.11

pylint 2.17.4
astroid 2.15.6
Python 3.11.4 (main, Jul  4 2023, 05:25:16) [GCC 12.2.0]

OS / Environment

Testing was done using the vanilla python:version docker images. e.g:

docker run --rm -v example.py:/tmp/example.py python:3.11 sh -c "pip install pylint && pylint /tmp/example.py"

Additional dependencies

No response

jacobtylerwalls commented 1 year ago

Thanks for the report.

Tentatively assigning to me, as I'd like to see if we can remove the HTTP brain entirely by just adding support for @_simple_enum instead.