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

Skip to content

Commit 2539649

Browse files
authored
Add a default for ssl.SSLContext.__new__ on 3.10+ (#9635)
1 parent 510bd46 commit 2539649

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

stdlib/ssl.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,13 @@ class SSLContext:
380380
post_handshake_auth: bool
381381
if sys.version_info >= (3, 10):
382382
security_level: int
383-
def __new__(cls: type[Self], protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ...
383+
if sys.version_info >= (3, 10):
384+
# Using the default (None) for the `protocol` parameter is deprecated,
385+
# but there isn't a good way of marking that in the stub unless/until PEP 702 is accepted
386+
def __new__(cls: type[Self], protocol: int | None = None, *args: Any, **kwargs: Any) -> Self: ...
387+
else:
388+
def __new__(cls: type[Self], protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ...
389+
384390
def cert_store_stats(self) -> dict[str, int]: ...
385391
def load_cert_chain(
386392
self, certfile: StrOrBytesPath, keyfile: StrOrBytesPath | None = None, password: _PasswordType | None = None

tests/stubtest_allowlists/py310.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ weakref.WeakValueDictionary.update
5353
unittest.TestCase.__init_subclass__
5454
unittest.case.TestCase.__init_subclass__
5555

56-
# stubtest complains that in 3.10 the default argument is inconsistent with the annotation,
57-
# but in 3.10+ calling the function without the default argument is in fact deprecated,
58-
# so it's better to ignore stubtest
59-
ssl.SSLContext.__new__
60-
6156
# SpooledTemporaryFile implements IO except these methods before Python 3.11
6257
# See also https://github.com/python/typeshed/pull/2452#issuecomment-420657918
6358
tempfile.SpooledTemporaryFile.__next__

tests/stubtest_allowlists/py311.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ weakref.WeakValueDictionary.update
4747
unittest.TestCase.__init_subclass__
4848
unittest.case.TestCase.__init_subclass__
4949

50-
# stubtest complains that in 3.10 the default argument is inconsistent with the annotation,
51-
# but in 3.10+ calling the function without the default argument is in fact deprecated,
52-
# so it's better to ignore stubtest
53-
ssl.SSLContext.__new__
54-
5550
# ==========
5651
# Related to positional-only arguments
5752
# ==========

0 commit comments

Comments
 (0)