Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d981f8

Browse files
authored
FixpyOpenSSL stubs to pass stubtest (#5657)
* Fix missing default arguments. * Fix wrong argument names. * Add constructor to `_EllipticCurve` and remove `name`.
1 parent c5b59b9 commit 4d981f8

3 files changed

Lines changed: 10 additions & 13 deletions

File tree

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
OpenSSL.SSL.Connection.__init__
2-
OpenSSL.SSL.Context.load_verify_locations
3-
OpenSSL.SSL.Context.set_verify
41
OpenSSL.crypto

stubs/pyOpenSSL/OpenSSL/SSL.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from socket import socket
1+
import socket
22
from typing import Callable, Sequence
33

44
from OpenSSL.crypto import X509
@@ -13,14 +13,14 @@ OP_NO_TLSv1_3: int
1313
VERIFY_PEER: int
1414

1515
class Connection:
16-
def __init__(self, context: Context, _socket: socket | None) -> None: ...
16+
def __init__(self, context: Context, socket: socket.socket | None = ...) -> None: ...
1717
def connect(self, addr: str | bytes | Sequence[str | int]) -> None: ...
1818
def do_handshake(self) -> None: ...
1919
def get_peer_certificate(self) -> X509: ...
2020
def set_tlsext_host_name(self, name: bytes) -> None: ...
2121

2222
class Context:
2323
def __init__(self, method: int) -> None: ...
24-
def load_verify_locations(self, cafile: str | None, capath: str | None) -> None: ...
24+
def load_verify_locations(self, cafile: str | None, capath: str | None = ...) -> None: ...
2525
def set_options(self, options: int) -> None: ...
26-
def set_verify(self, mode: int, callback: Callable[[Connection, X509, int, int, int], bool]) -> None: ...
26+
def set_verify(self, mode: int, callback: Callable[[Connection, X509, int, int, int], bool] | None = ...) -> None: ...

stubs/pyOpenSSL/OpenSSL/crypto.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import Callable, Iterable, List, Sequence, Set, Text, Tuple, Union
2+
from typing import Any, Callable, Iterable, List, Sequence, Set, Text, Tuple, Union
33

44
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey
55
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
@@ -15,7 +15,7 @@ TYPE_RSA: int
1515
TYPE_DSA: int
1616

1717
class _EllipticCurve:
18-
name: Text
18+
def __init__(self, lib: Any | None, nid: int, name: str) -> None: ...
1919

2020
class Error(Exception): ...
2121

@@ -53,7 +53,7 @@ class X509:
5353
def add_extensions(self, extensions: Iterable[X509Extension]) -> None: ...
5454
def digest(self, digest_name: bytes) -> bytes: ...
5555
@classmethod
56-
def from_cryptography(cls, crypto_key: Certificate) -> X509: ...
56+
def from_cryptography(cls, crypto_cert: Certificate) -> X509: ...
5757
def get_extension(self, index: int) -> X509Extension: ...
5858
def get_extension_count(self) -> int: ...
5959
def get_issuer(self) -> X509Name: ...
@@ -129,12 +129,12 @@ class X509Store:
129129
def __init__(self) -> None: ...
130130
def add_cert(self, cert: X509) -> None: ...
131131
def add_crl(self, crl: CRL) -> None: ...
132-
def load_locations(self, cafile: Text | bytes, capath: Text | bytes) -> None: ...
132+
def load_locations(self, cafile: Text | bytes, capath: Text | bytes | None = ...) -> None: ...
133133
def set_flags(self, flags: int) -> None: ...
134134
def set_time(self, vfy_time: datetime) -> None: ...
135135

136136
class X509StoreContext:
137-
def __init__(self, store: X509Store, certificate: X509, chain: Sequence[X509] | None) -> None: ...
137+
def __init__(self, store: X509Store, certificate: X509, chain: Sequence[X509] | None = ...) -> None: ...
138138
def get_verified_chain(self) -> List[X509]: ...
139139
def set_store(self, store: X509Store) -> None: ...
140140
def verify_certificate(self) -> None: ...
@@ -187,7 +187,7 @@ def get_elliptic_curves() -> Set[_EllipticCurve]: ...
187187
def get_elliptic_curve(name: Text) -> _EllipticCurve: ...
188188
def dump_certificate(type: int, cert: X509) -> bytes: ...
189189
def load_certificate(type: int, buffer: bytes) -> X509: ...
190-
def dump_certificate_request(type: int, cert: X509Req) -> bytes: ...
190+
def dump_certificate_request(type: int, req: X509Req) -> bytes: ...
191191
def load_certificate_request(type: int, buffer: bytes) -> X509Req: ...
192192
def dump_privatekey(
193193
type: int, pkey: PKey, cipher: bytes | None = ..., passphrase: bytes | Callable[[], bytes] | None = ...

0 commit comments

Comments
 (0)