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

ssl.VerifyMode and other Enums not recognized #3691

Closed
cipherboy opened this issue Jun 15, 2020 · 1 comment · Fixed by pylint-dev/astroid#1381
Closed

ssl.VerifyMode and other Enums not recognized #3691

cipherboy opened this issue Jun 15, 2020 · 1 comment · Fixed by pylint-dev/astroid#1381
Labels
Bug 🪲 Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade)

Comments

@cipherboy
Copy link

cipherboy commented Jun 15, 2020

Steps to reproduce

  1. Recreate this file:
#!/usr/bin/python3

"""
Proof of Concept: ssl.VerifyMode isn't understood by pylint
"""

import ssl

print(ssl.VerifyMode)
  1. Run pylint against it:
$ ~/.local/bin/pylint ./example.py
************* Module example
example.py:9:6: E1101: Module 'ssl' has no 'VerifyMode' member (no-member)

----------------------------------------------------------------------
Your code has been rated at -15.00/10 (previous run: -15.00/10, +0.00)

$ ~/.local/bin/pylint --version
pylint 2.5.3
astroid 2.4.2
Python 3.8.3 (default, May 15 2020, 00:00:00) 
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]
$ pylint-3 ./example.py
************* Module example
example.py:9:6: E1101: Module 'ssl' has no 'VerifyMode' member (no-member)

----------------------------------------------------------------------
Your code has been rated at -15.00/10 (previous run: -15.00/10, +0.00)
$ pylint-3 --version
pylint 2.4.4
astroid 2.3.3
Python 3.8.3 (default, May 15 2020, 00:00:00) 
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]
  1. Notice that the member does exist:
$ python3 ./example.py
<enum 'VerifyMode'>
$ python3 --version
Python 3.8.3

Current behavior

ssl.VerifyMode doesn't get detected

Expected behavior

ssl.VerifyMode should be detected.

pylint --version output

pylint 2.5.3
astroid 2.4.2
Python 3.8.3 (default, May 15 2020, 00:00:00) 
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]

and

pylint 2.4.4
astroid 2.3.3
Python 3.8.3 (default, May 15 2020, 00:00:00) 
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]

I believe this has to do with how it is constructed in the module:

_IntEnum._convert_(
    '_SSLMethod', __name__,
    lambda name: name.startswith('PROTOCOL_') and name != 'PROTOCOL_SSLv23',
    source=_ssl)

_IntFlag._convert_(
    'Options', __name__,
    lambda name: name.startswith('OP_'),
    source=_ssl)

_IntEnum._convert_(
    'AlertDescription', __name__,
    lambda name: name.startswith('ALERT_DESCRIPTION_'),
    source=_ssl)

_IntEnum._convert_(
    'SSLErrorNumber', __name__,
    lambda name: name.startswith('SSL_ERROR_'),
    source=_ssl)

_IntFlag._convert_(
    'VerifyFlags', __name__,
    lambda name: name.startswith('VERIFY_'),
    source=_ssl)

_IntEnum._convert_(
    'VerifyMode', __name__,
    lambda name: name.startswith('CERT_'),
    source=_ssl)
@brycepg brycepg added Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Bug 🪲 labels Jun 16, 2020
@brycepg
Copy link
Contributor

brycepg commented Jun 16, 2020

Thanks for the report. I can verify this bug. If someone would like to have a go at fixing this, I would recommend populating these variables in astroid using a brain tip. See http://pylint.pycqa.org/projects/astroid/en/latest/extending.html#ast-inference-tip-transforms and https://github.com/PyCQA/astroid/tree/master/astroid/brain

cipherboy added a commit to cipherboy/astroid that referenced this issue Feb 4, 2022
astroid's brian_ssl wrapper lacks several enums constructed in the core
ssl module. This eventually affects pylint's ability to parse code which
makes use of these enums:

> example.py:9:6: E1101: Module 'ssl' has no 'VerifyMode' member (no-member)

Adding these enums to brain_ssl fixes the reported issue against pylint.

See also: pylint-dev/pylint#3691

Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>
cipherboy added a commit to cipherboy/astroid that referenced this issue Feb 4, 2022
astroid's brian_ssl wrapper lacks several enums constructed in the core
ssl module. This eventually affects pylint's ability to parse code which
makes use of these enums:

> example.py:9:6: E1101: Module 'ssl' has no 'VerifyMode' member (no-member)

Adding these enums to brain_ssl fixes the reported issue against pylint.

See also: pylint-dev/pylint#3691

Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade)
Projects
None yet
2 participants