Skip to content

Add the ssl OP_* and VERIFY_* constants missing from the ssl brain - #3444

Open
LindseyZ1205 wants to merge 2 commits into
pylint-dev:mainfrom
LindseyZ1205:fix/ssl-brain-constants
Open

LindseyZ1205 wants to merge 2 commits into
pylint-dev:mainfrom
LindseyZ1205:fix/ssl-brain-constants

Conversation

@LindseyZ1205

@LindseyZ1205 LindseyZ1205 commented Oct 24, 2026 •

Copy link
Copy Markdown

Type of Changes

Type
✓ 🐛 Bug fix

Description

ssl creates its OP_* and VERIFY_* constants at import time with _IntFlag._convert_(..., source=_ssl), so the ssl brain lists them. But several constants that the brain's Options and VerifyFlags enums already have aren't imported from _ssl as module attributes, and OP_IGNORE_UNEXPECTED_EOF (new in Python 3.10) and OP_ENABLE_KTLS (new in Python 3.12) are missing from both. So pylint reports common settings such as

import ssl

context = ssl.create_default_context()
context.options |= ssl.OP_IGNORE_UNEXPECTED_EOF
context.verify_flags &= ~ssl.VERIFY_X509_PARTIAL_CHAIN

as E1101: Module 'ssl' has no 'OP_IGNORE_UNEXPECTED_EOF' member (no-member), and from ssl import OP_NO_TICKET as no-name-in-module. The affected names are OP_ENABLE_KTLS, OP_ENABLE_MIDDLEBOX_COMPAT, OP_IGNORE_UNEXPECTED_EOF, OP_NO_RENEGOTIATION, OP_NO_TICKET, OP_NO_TLSv1_3, VERIFY_ALLOW_PROXY_CERTS, VERIFY_X509_PARTIAL_CHAIN and VERIFY_X509_TRUSTED_FIRST. I found them by writing out every public attribute that the stdlib modules have at runtime on Python 3.14 and running pylint's no-member on the result: these are the only ssl names it reports.

This change imports them from _ssl, and adds OP_IGNORE_UNEXPECTED_EOF and, on Python 3.12+, OP_ENABLE_KTLS to Options, as #2489 did for OP_LEGACY_SERVER_CONNECT. Like OP_NO_COMPRESSION and OP_SINGLE_ECDH_USE, which the brain already imports, some of these are only defined when OpenSSL has them (OP_IGNORE_UNEXPECTED_EOF and OP_ENABLE_KTLS need OpenSSL 3.0), so the new test skips a name that the running ssl doesn't have. It doesn't touch the PROTOCOL_* imports that #3161 changes, and the two merge cleanly.

Tests: test_ssl_brain_options_and_verify_flags in tests/brain/test_ssl.py checks that each name is inferred as a constant of the module and as a member of its enum. Its 9 cases fail on main and pass with this change on Python 3.14 (OpenSSL 3.6), 3.13 and 3.12. With this change, pylint main reports no errors for the snippets above. The whole test suite has 2470 passed with this change and 2461 on main (Python 3.14); the same three tests in tests/test_manager.py and tests/test_get_relative_base_path.py fail in both because of my local setup (Homebrew Python on macOS, without pkg_resources). ruff, black, pylint and mypy report nothing on the changed files.

ssl creates these constants at import time from _ssl, and the brain
didn't list all of them as module attributes, so they were reported as
missing members. OP_IGNORE_UNEXPECTED_EOF and OP_ENABLE_KTLS were also
missing from the Options enum.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Brain 🧠 Needs a brain tip Bug 🪳

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants