File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ Release date: TBA
19
19
20
20
* Implement inference for JoinedStr and FormattedValue
21
21
22
+ * Add support for ``ssl.OP_LEGACY_SERVER_CONNECT`` (new in Python 3.12).
23
+
24
+ Closes pylint-dev/pylint#9849
22
25
23
26
24
27
What's New in astroid 3.2.5?
Original file line number Diff line number Diff line change 6
6
7
7
from astroid import parse
8
8
from astroid .brain .helpers import register_module_extender
9
- from astroid .const import PY310_PLUS
9
+ from astroid .const import PY310_PLUS , PY312_PLUS
10
10
from astroid .manager import AstroidManager
11
11
12
12
@@ -42,13 +42,16 @@ class Options(_IntFlag):
42
42
OP_NO_COMPRESSION = 11
43
43
OP_NO_TICKET = 12
44
44
OP_NO_RENEGOTIATION = 13
45
- OP_ENABLE_MIDDLEBOX_COMPAT = 14"""
45
+ OP_ENABLE_MIDDLEBOX_COMPAT = 14
46
+ """
47
+ if PY312_PLUS :
48
+ enum += "OP_LEGACY_SERVER_CONNECT = 15"
46
49
return enum
47
50
48
51
49
52
def ssl_transform ():
50
53
return parse (
51
- """
54
+ f """
52
55
# Import necessary for conversion of objects defined in C into enums
53
56
from enum import IntEnum as _IntEnum, IntFlag as _IntFlag
54
57
@@ -71,6 +74,8 @@ def ssl_transform():
71
74
OP_NO_TLSv1, OP_NO_TLSv1_1, OP_NO_TLSv1_2,
72
75
OP_SINGLE_DH_USE, OP_SINGLE_ECDH_USE)
73
76
77
+ { "from _ssl import OP_LEGACY_SERVER_CONNECT" if PY312_PLUS else "" }
78
+
74
79
from _ssl import (ALERT_DESCRIPTION_ACCESS_DENIED, ALERT_DESCRIPTION_BAD_CERTIFICATE,
75
80
ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE,
76
81
ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE,
Original file line number Diff line number Diff line change 4
4
5
5
"""Tests for the ssl brain."""
6
6
7
+ import pytest
8
+
7
9
from astroid import bases , nodes , parse
10
+ from astroid .const import PY312_PLUS
8
11
9
12
10
13
def test_ssl_brain () -> None :
@@ -41,3 +44,21 @@ def test_ssl_brain() -> None:
41
44
inferred_cert_required = next (module .body [4 ].value .infer ())
42
45
assert isinstance (inferred_cert_required , bases .Instance )
43
46
assert inferred_cert_required ._proxied .name == "CERT_REQUIRED"
47
+
48
+
49
+ @pytest .mark .skipif (not PY312_PLUS , reason = "Uses new 3.12 constant" )
50
+ def test_ssl_brain_py312 () -> None :
51
+ """Test ssl brain transform."""
52
+ module = parse (
53
+ """
54
+ import ssl
55
+ ssl.OP_LEGACY_SERVER_CONNECT
56
+ ssl.Options.OP_LEGACY_SERVER_CONNECT
57
+ """
58
+ )
59
+
60
+ inferred_constant = next (module .body [1 ].value .infer ())
61
+ assert isinstance (inferred_constant , nodes .Const )
62
+
63
+ inferred_instance = next (module .body [2 ].value .infer ())
64
+ assert isinstance (inferred_instance , bases .Instance )
You can’t perform that action at this time.
0 commit comments