Skip to content

Commit b3035c7

Browse files
committed
Convert set-like containers to frozenset
1 parent b852618 commit b3035c7

File tree

4 files changed

+47
-39
lines changed

4 files changed

+47
-39
lines changed

sphinx/builders/latex/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
'el-polyton': '-L greek-polytonic -C utf8 ',
103103
} # fmt: skip
104104

105-
XINDY_CYRILLIC_SCRIPTS = ['be', 'bg', 'mk', 'mn', 'ru', 'sr', 'sh', 'uk']
105+
XINDY_CYRILLIC_SCRIPTS = frozenset({'be', 'bg', 'mk', 'mn', 'ru', 'sr', 'sh', 'uk'})
106106

107107
logger = logging.getLogger(__name__)
108108

sphinx/domains/c/_ids.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from __future__ import annotations
22

33
import re
4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from collections.abc import Sequence, Set
48

59
# https://en.cppreference.com/w/c/keyword
6-
_keywords = [
10+
_keywords: Set[str] = frozenset({
711
'auto',
812
'break',
913
'case', 'char', 'const', 'continue',
@@ -28,10 +32,10 @@
2832
'_Noreturn',
2933
'_Static_assert',
3034
'_Thread_local',
31-
] # fmt: skip
35+
}) # fmt: skip
3236
# These are only keyword'y when the corresponding headers are included.
3337
# They are used as default value for c_extra_keywords.
34-
_macro_keywords = [
38+
_macro_keywords: Set[str] = frozenset({
3539
'alignas',
3640
'alignof',
3741
'bool',
@@ -40,23 +44,23 @@
4044
'noreturn',
4145
'static_assert',
4246
'thread_local',
43-
]
47+
})
4448

4549
# these are ordered by precedence
46-
_expression_bin_ops = [
47-
['||', 'or'],
48-
['&&', 'and'],
49-
['|', 'bitor'],
50-
['^', 'xor'],
51-
['&', 'bitand'],
52-
['==', '!=', 'not_eq'],
53-
['<=', '>=', '<', '>'],
54-
['<<', '>>'],
55-
['+', '-'],
56-
['*', '/', '%'],
57-
['.*', '->*'],
50+
_expression_bin_ops: Sequence[tuple[str, ...]] = [
51+
('||', 'or'),
52+
('&&', 'and'),
53+
('|', 'bitor'),
54+
('^', 'xor'),
55+
('&', 'bitand'),
56+
('==', '!=', 'not_eq'),
57+
('<=', '>=', '<', '>'),
58+
('<<', '>>'),
59+
('+', '-'),
60+
('*', '/', '%'),
61+
('.*', '->*'),
5862
]
59-
_expression_unary_ops = [
63+
_expression_unary_ops: Sequence[str] = [
6064
'++',
6165
'--',
6266
'*',
@@ -68,7 +72,7 @@
6872
'~',
6973
'compl',
7074
]
71-
_expression_assignment_ops = [
75+
_expression_assignment_ops: Sequence[str] = [
7276
'=',
7377
'*=',
7478
'/=',
@@ -86,7 +90,7 @@
8690
]
8791

8892
_max_id = 1
89-
_id_prefix = [None, 'c.', 'Cv2.']
93+
_id_prefix: Sequence[str] = ('', 'c.', 'Cv2.')
9094
# Ids are used in lookup keys which are used across pickled files,
9195
# so when _max_id changes, make sure to update the ENV_VERSION.
9296

sphinx/domains/cpp/_ids.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@
253253
from __future__ import annotations
254254

255255
import re
256+
from typing import TYPE_CHECKING
257+
258+
if TYPE_CHECKING:
259+
from collections.abc import Sequence, Set
256260

257261
udl_identifier_re = re.compile(
258262
r'[a-zA-Z_][a-zA-Z0-9_]*\b' # note, no word boundary in the beginning
@@ -286,7 +290,7 @@
286290
re.VERBOSE,
287291
)
288292
# see https://en.cppreference.com/w/cpp/keyword
289-
_keywords = [
293+
_keywords: Set[str] = frozenset({
290294
'alignas', 'alignof', 'and', 'and_eq', 'asm', 'auto',
291295
'bitand', 'bitor', 'bool', 'break',
292296
'case', 'catch', 'class', 'compl', 'concept', 'continue',
@@ -311,7 +315,7 @@
311315
'virtual', 'void', 'volatile',
312316
'wchar_t', 'while',
313317
'xor', 'xor_eq',
314-
] # fmt: skip
318+
}) # fmt: skip
315319

316320

317321
_simple_type_specifiers_re = re.compile(
@@ -332,7 +336,7 @@
332336
)
333337

334338
_max_id = 4
335-
_id_prefix = [None, '', '_CPPv2', '_CPPv3', '_CPPv4']
339+
_id_prefix: Sequence[str] = ('', '', '_CPPv2', '_CPPv3', '_CPPv4')
336340
# Ids are used in lookup keys which are used across pickled files,
337341
# so when _max_id changes, make sure to update the ENV_VERSION.
338342

@@ -553,20 +557,20 @@
553557
'L': 'w',
554558
}
555559
# these are ordered by preceedence
556-
_expression_bin_ops = [
557-
['||', 'or'],
558-
['&&', 'and'],
559-
['|', 'bitor'],
560-
['^', 'xor'],
561-
['&', 'bitand'],
562-
['==', '!=', 'not_eq'],
563-
['<=>', '<=', '>=', '<', '>'],
564-
['<<', '>>'],
565-
['+', '-'],
566-
['*', '/', '%'],
567-
['.*', '->*'],
560+
_expression_bin_ops: Sequence[tuple[str, ...]] = [
561+
('||', 'or'),
562+
('&&', 'and'),
563+
('|', 'bitor'),
564+
('^', 'xor'),
565+
('&', 'bitand'),
566+
('==', '!=', 'not_eq'),
567+
('<=>', '<=', '>=', '<', '>'),
568+
('<<', '>>'),
569+
('+', '-'),
570+
('*', '/', '%'),
571+
('.*', '->*'),
568572
]
569-
_expression_unary_ops = [
573+
_expression_unary_ops: Sequence[str] = [
570574
'++',
571575
'--',
572576
'*',
@@ -578,7 +582,7 @@
578582
'~',
579583
'compl',
580584
]
581-
_expression_assignment_ops = [
585+
_expression_assignment_ops: Sequence[str] = [
582586
'=',
583587
'*=',
584588
'/=',

sphinx/ext/autodoc/directive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
'no-value',
3939
]
4040

41-
AUTODOC_EXTENDABLE_OPTIONS = [
41+
AUTODOC_EXTENDABLE_OPTIONS = frozenset({
4242
'members',
4343
'private-members',
4444
'special-members',
4545
'exclude-members',
46-
]
46+
})
4747

4848

4949
class DummyOptionSpec(dict[str, Callable[[str], str]]):

0 commit comments

Comments
 (0)