Skip to content

Fix type of ssl.Options.OP_ALL - #16380

Merged
srittau merged 1 commit into
python:mainfrom
chiliec:fix-ssl-options-op-all
Sep 10, 2026
Merged

srittau merged 1 commit into
python:mainfrom
chiliec:fix-ssl-options-op-all

Conversation

@chiliec

@chiliec chiliec commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Closes #16378

Options.OP_ALL was declared as OP_ALL: int (since #15589, because its runtime value differs between OpenSSL builds), which makes type checkers treat it as a non-member attribute of type int rather than an enum member. So Options.OP_ALL is not assignable to Options, unlike every other flag in the class.

Per the typing spec for enums in stubs, a member whose value we don't want to pin can be declared as OP_ALL = ..., as suggested by @srittau in the issue. That's what this PR does.

Verified locally with the issue's reproducer (--custom-typeshed-dir pointing at this branch):

  • mypy 2.3.0: before → Revealed type is "int" + Argument 1 to "f" has incompatible type "int"; expected "Options"; after → Revealed type is "Literal[ssl.Options.OP_ALL]?", no errors.
  • pyright 1.1.411: after → Type of "Options.OP_ALL" is "Literal[Options.OP_ALL]", 0 errors.
  • stubtest ssl (py3.11, linux allowlists): no issues, same as main.
  • tests/mypy_test.py stdlib/ssl.pyi -p 3.11 -p 3.13: success.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
srittau merged commit 2fd0f31 into python:main Sep 10, 2026
88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong type for ssl.Options.OP_ALL

2 participants