Skip to content

Commit

Permalink
Fixes for recent mypy
Browse files Browse the repository at this point in the history
Including ALPN typing which was totally broken
  • Loading branch information
alex committed Jan 7, 2025
1 parent d3489af commit 675ef3c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/OpenSSL/SSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ class _NoOverlappingProtocols:
_ALPNSelectCallback = Callable[
[
"Connection",
typing.Union[typing.List[bytes], _NoOverlappingProtocols],
typing.List[bytes],
],
None,
typing.Union[bytes, _NoOverlappingProtocols],
]
_CookieGenerateCallback = Callable[["Connection"], bytes]
_CookieVerifyCallback = Callable[["Connection", bytes], bool]
Expand Down Expand Up @@ -1889,7 +1889,7 @@ def __init__(
# Negotiation. These strings get copied at some point but it's well
# after the callback returns, so we have to hang them somewhere to
# avoid them getting freed.
self._alpn_select_callback_args = None
self._alpn_select_callback_args: Any = None

# Reference the verify_callback of the Context. This ensures that if
# set_verify is called again after the SSL object has been created we
Expand Down
5 changes: 4 additions & 1 deletion src/OpenSSL/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

from cryptography.hazmat.bindings.openssl.binding import Binding

StrOrBytesPath = Union[str, bytes, os.PathLike]
if sys.version_info >= (3, 9):
StrOrBytesPath = Union[str, bytes, os.PathLike[str], os.PathLike[bytes]]
else:
StrOrBytesPath = Union[str, bytes, os.PathLike]

binding = Binding()
ffi = binding.ffi
Expand Down
3 changes: 1 addition & 2 deletions src/OpenSSL/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from base64 import b16encode
from collections.abc import Iterable, Sequence
from functools import partial
from os import PathLike
from typing import (
Any,
Callable,
Expand All @@ -24,6 +23,7 @@
rsa,
)

from OpenSSL._util import StrOrBytesPath
from OpenSSL._util import (
byte_string as _byte_string,
)
Expand Down Expand Up @@ -87,7 +87,6 @@
rsa.RSAPublicKey,
]
_Key = Union[_PrivateKey, _PublicKey]
StrOrBytesPath = Union[str, bytes, PathLike]
PassphraseCallableT = Union[bytes, Callable[..., bytes]]


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ commands =

[testenv:py311-mypy]
deps =
mypy==1.1.1
mypy
skip_install = true
commands =
mypy src
Expand Down

0 comments on commit 675ef3c

Please sign in to comment.