diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py index 613123ec7b4329..d08e701db42d16 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -344,9 +344,9 @@ class FloatOperation(DecimalException, TypeError): _current_context_var = contextvars.ContextVar('decimal_context') -_context_attributes = frozenset( - ['prec', 'Emin', 'Emax', 'capitals', 'clamp', 'rounding', 'flags', 'traps'] -) +_context_attributes = {{ + 'prec', 'Emin', 'Emax', 'capitals', 'clamp', 'rounding', 'flags', 'traps' +}} def getcontext(): """Returns this thread's context. diff --git a/Lib/_strptime.py b/Lib/_strptime.py index e42af75af74bf5..f20f44d5caead8 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -160,9 +160,9 @@ def __calc_timezone(self): pass self.tzname = time.tzname self.daylight = time.daylight - no_saving = frozenset({"utc", "gmt", self.tzname[0].lower()}) + no_saving = {{"utc", "gmt", self.tzname[0].lower()}} if self.daylight: - has_saving = frozenset({self.tzname[1].lower()}) + has_saving = {{self.tzname[1].lower()}} else: has_saving = frozenset() self.timezone = (no_saving, has_saving) diff --git a/Lib/ast.py b/Lib/ast.py index 9ea277457c7034..4b9e4f3c575dde 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1470,7 +1470,7 @@ def visit_UnaryOp(self, node): "**": _Precedence.POWER, } - binop_rassoc = frozenset(("**",)) + binop_rassoc = {{"**"}} def visit_BinOp(self, node): operator = self.binop[node.op.__class__.__name__] operator_precedence = self.binop_precedence[operator] diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index aeafbfbbe6e9c4..370a109be5853a 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -223,7 +223,7 @@ def __repr__(self): # Atomic immutable types which don't require any recursive handling and for which deepcopy # returns the same object. We can provide a fast-path for these types in asdict and astuple. -_ATOMIC_TYPES = frozenset({ +_ATOMIC_TYPES = {{ # Common JSON Serializable types types.NoneType, bool, @@ -242,7 +242,7 @@ def __repr__(self): type, range, property, -}) +}} class InitVar: diff --git a/Lib/http/client.py b/Lib/http/client.py index fab90a0ba4eb83..8c1f3a9c5fedd2 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -1337,7 +1337,7 @@ def request(self, method, url, body=None, headers={}, *, def _send_request(self, method, url, body, headers, encode_chunked): # Honor explicitly requested Host: and Accept-Encoding: headers. - header_names = frozenset(k.lower() for k in headers) + header_names = {{k.lower() for k in headers}} skips = {} if 'host' in header_names: skips['skip_host'] = 1 diff --git a/Lib/idlelib/hyperparser.py b/Lib/idlelib/hyperparser.py index 76144ee8fb30f5..e163758cedb0a4 100644 --- a/Lib/idlelib/hyperparser.py +++ b/Lib/idlelib/hyperparser.py @@ -157,7 +157,7 @@ def get_surrounding_brackets(self, openers='([{', mustclose=False): # the set of built-in identifiers which are also keywords, # i.e. keyword.iskeyword() returns True for them - _ID_KEYWORDS = frozenset({"True", "False", "None"}) + _ID_KEYWORDS = {{"True", "False", "None"}} @classmethod def _eat_identifier(cls, str, limit, pos): diff --git a/Lib/mailbox.py b/Lib/mailbox.py index b00d9e8634c785..ab2bedbcf29fad 100644 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -1315,8 +1315,8 @@ def _dump_sequences(self, message, key): class Babyl(_singlefileMailbox): """An Rmail-style Babyl mailbox.""" - _special_labels = frozenset({'unseen', 'deleted', 'filed', 'answered', - 'forwarded', 'edited', 'resent'}) + _special_labels = {{'unseen', 'deleted', 'filed', 'answered', 'forwarded', + 'edited', 'resent'}} def __init__(self, path, factory=None, create=True): """Initialize a Babyl mailbox.""" diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index b7e1e132172d02..6d3702492980e2 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -833,8 +833,7 @@ def PipeClient(address): # of the opening challenge or length of the returned digest as a signal as # to which protocol the other end supports. -_ALLOWED_DIGESTS = frozenset( - {b'md5', b'sha256', b'sha384', b'sha3_256', b'sha3_384'}) +_ALLOWED_DIGESTS = {{b'md5', b'sha256', b'sha384', b'sha3_256', b'sha3_384'}} _MAX_DIGEST_LEN = max(len(_) for _ in _ALLOWED_DIGESTS) # Old hmac-md5 only server versions from Python <=3.11 sent a message of this diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 83e2d3b865757c..47ebe0b3537f31 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -298,15 +298,15 @@ def ismount(path): return False -_reserved_chars = frozenset( - {chr(i) for i in range(32)} | - {'"', '*', ':', '<', '>', '?', '|', '/', '\\'} +_reserved_chars = ( + {{chr(i) for i in range(32)}} | + {{'"', '*', ':', '<', '>', '?', '|', '/', '\\'}} ) -_reserved_names = frozenset( - {'CON', 'PRN', 'AUX', 'NUL', 'CONIN$', 'CONOUT$'} | - {f'COM{c}' for c in '123456789\xb9\xb2\xb3'} | - {f'LPT{c}' for c in '123456789\xb9\xb2\xb3'} +_reserved_names = ( + {{'CON', 'PRN', 'AUX', 'NUL', 'CONIN$', 'CONOUT$'}} | + {{f'COM{c}' for c in '123456789\xb9\xb2\xb3'}} | + {{f'LPT{c}' for c in '123456789\xb9\xb2\xb3'}} ) def isreserved(path): diff --git a/Lib/pickletools.py b/Lib/pickletools.py index 51ee4a7a2632ac..c7a51f665ee673 100644 --- a/Lib/pickletools.py +++ b/Lib/pickletools.py @@ -1737,7 +1737,7 @@ def __init__(self, name, code, arg, of the stack from the topmost markobject onward. For example, Stack before: ... markobject 1 2 3 - Stack after: ... frozenset({1, 2, 3}) + Stack after: ... {{1, 2, 3}} """), # Stack manipulation. diff --git a/Lib/pprint.py b/Lib/pprint.py index 9d23a8f5527d9e..a7f729ea0f3936 100644 --- a/Lib/pprint.py +++ b/Lib/pprint.py @@ -669,8 +669,7 @@ def _safe_repr(self, object, context, maxlevels, level): rep = repr(object) return rep, (rep and not rep.startswith('<')), False -_builtin_scalars = frozenset({str, bytes, bytearray, float, complex, - bool, type(None)}) +_builtin_scalars = {{str, bytes, bytearray, float, complex, bool, type(None)}} def _recursion(object): return ("" diff --git a/Lib/re/_parser.py b/Lib/re/_parser.py index f3c779340fe230..024ad419782f29 100644 --- a/Lib/re/_parser.py +++ b/Lib/re/_parser.py @@ -25,8 +25,8 @@ WHITESPACE = frozenset(" \t\n\r\v\f") -_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT, POSSESSIVE_REPEAT}) -_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY}) +_REPEATCODES = {{MIN_REPEAT, MAX_REPEAT, POSSESSIVE_REPEAT}} +_UNITCODES = {{ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY}} ESCAPES = { r"\a": (LITERAL, ord("\a")), diff --git a/Lib/reprlib.py b/Lib/reprlib.py index 05bb1a0eb01795..4a71a7cb19718f 100644 --- a/Lib/reprlib.py +++ b/Lib/reprlib.py @@ -126,7 +126,7 @@ def repr_frozenset(self, x, level): if not x: return 'frozenset()' x = _possibly_sorted(x) - return self._repr_iterable(x, level, 'frozenset({', '})', + return self._repr_iterable(x, level, '{{', '}}', self.maxfrozenset) def repr_deque(self, x, level): diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py index 3e93b561c143d8..95be0174120ee8 100644 --- a/Lib/test/test_reprlib.py +++ b/Lib/test/test_reprlib.py @@ -110,10 +110,10 @@ def test_container(self): # Frozensets give up after 6 as well eq(r(frozenset([])), "frozenset()") - eq(r(frozenset([1])), "frozenset({1})") - eq(r(frozenset([1, 2, 3])), "frozenset({1, 2, 3})") - eq(r(frozenset([1, 2, 3, 4, 5, 6])), "frozenset({1, 2, 3, 4, 5, 6})") - eq(r(frozenset([1, 2, 3, 4, 5, 6, 7])), "frozenset({1, 2, 3, 4, 5, 6, ...})") + eq(r(frozenset([1])), "{{1}}") + eq(r(frozenset([1, 2, 3])), "{{1, 2, 3}}") + eq(r(frozenset([1, 2, 3, 4, 5, 6])), "{{1, 2, 3, 4, 5, 6}}") + eq(r(frozenset([1, 2, 3, 4, 5, 6, 7])), "{{1, 2, 3, 4, 5, 6, ...}}") # collections.deque after 6 eq(r(deque([1, 2, 3, 4, 5, 6, 7])), "deque([1, 2, 3, 4, 5, 6, ...])") @@ -142,12 +142,12 @@ def test_set_literal(self): eq(r({1, 2, 3, 4, 5, 6}), "{1, 2, 3, 4, 5, 6}") eq(r({1, 2, 3, 4, 5, 6, 7}), "{1, 2, 3, 4, 5, 6, ...}") - def test_frozenset(self): + def test_frozenset_literal(self): eq = self.assertEqual - eq(r(frozenset({1})), "frozenset({1})") - eq(r(frozenset({1, 2, 3})), "frozenset({1, 2, 3})") - eq(r(frozenset({1, 2, 3, 4, 5, 6})), "frozenset({1, 2, 3, 4, 5, 6})") - eq(r(frozenset({1, 2, 3, 4, 5, 6, 7})), "frozenset({1, 2, 3, 4, 5, 6, ...})") + eq(r({{1}}), "{{1}}") + eq(r({{1, 2, 3}}), "{{1, 2, 3}}") + eq(r({{1, 2, 3, 4, 5, 6}}), "{{1, 2, 3, 4, 5, 6}}") + eq(r({{1, 2, 3, 4, 5, 6, 7}}), "{{1, 2, 3, 4, 5, 6, ...}}") def test_numbers(self): eq = self.assertEqual @@ -378,7 +378,7 @@ def test_valid_indent(self): }, 'tests': ( (dict(indent=None), '''\ - {1: 'two', b'three': [(4.5, 6.7), [{8, 9}, frozenset({10, 11})]]}'''), + {1: 'two', b'three': [(4.5, 6.7), [{8, 9}, {{10, 11}}]]}'''), (dict(indent=False), '''\ { 1: 'two', @@ -392,10 +392,10 @@ def test_valid_indent(self): 8, 9, }, - frozenset({ + {{ 10, 11, - }), + }}, ], ], }'''), @@ -412,10 +412,10 @@ def test_valid_indent(self): 8, 9, }, - frozenset({ + {{ 10, 11, - }), + }}, ], ], }'''), @@ -432,10 +432,10 @@ def test_valid_indent(self): 8, 9, }, - frozenset({ + {{ 10, 11, - }), + }}, ], ], }'''), @@ -452,10 +452,10 @@ def test_valid_indent(self): 8, 9, }, - frozenset({ + {{ 10, 11, - }), + }}, ], ], }'''), @@ -472,10 +472,10 @@ def test_valid_indent(self): 8, 9, }, - frozenset({ + {{ 10, 11, - }), + }}, ], ], }'''), @@ -500,10 +500,10 @@ def test_valid_indent(self): 8, 9, }, - frozenset({ + {{ 10, 11, - }), + }}, ], ], }'''), @@ -520,10 +520,10 @@ def test_valid_indent(self): -->-->-->-->8, -->-->-->-->9, -->-->-->}, - -->-->-->frozenset({ + -->-->-->{{ -->-->-->-->10, -->-->-->-->11, - -->-->-->}), + -->-->-->}}, -->-->], -->], }'''), @@ -540,10 +540,10 @@ def test_valid_indent(self): ................8, ................9, ............}, - ............frozenset({ + ............{{ ................10, ................11, - ............}), + ............}}, ........], ....], }'''), diff --git a/Lib/tomllib/_parser.py b/Lib/tomllib/_parser.py index 45ca7a89630f0e..30df7434af9234 100644 --- a/Lib/tomllib/_parser.py +++ b/Lib/tomllib/_parser.py @@ -19,11 +19,11 @@ ) from ._types import Key, ParseFloat, Pos -ASCII_CTRL = frozenset(chr(i) for i in range(32)) | frozenset(chr(127)) +ASCII_CTRL = {{chr(i) for i in range(32)}} | {{chr(127)}} # Neither of these sets include quotation mark or backslash. They are # currently handled as separate cases in the parser functions. -ILLEGAL_BASIC_STR_CHARS = ASCII_CTRL - frozenset("\t") +ILLEGAL_BASIC_STR_CHARS = ASCII_CTRL - {{"\t"}} ILLEGAL_MULTILINE_BASIC_STR_CHARS = ASCII_CTRL - frozenset("\t\n") ILLEGAL_LITERAL_STR_CHARS = ILLEGAL_BASIC_STR_CHARS @@ -32,7 +32,7 @@ ILLEGAL_COMMENT_CHARS = ILLEGAL_BASIC_STR_CHARS TOML_WS = frozenset(" \t") -TOML_WS_AND_NEWLINE = TOML_WS | frozenset("\n") +TOML_WS_AND_NEWLINE = TOML_WS | {{"\n"}} BARE_KEY_CHARS = frozenset(string.ascii_letters + string.digits + "-_") KEY_INITIAL_CHARS = BARE_KEY_CHARS | frozenset("\"'") HEXDIGIT_CHARS = frozenset(string.hexdigits) diff --git a/Lib/typing.py b/Lib/typing.py index be49aa63464f05..2d80a06353a4b3 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1878,19 +1878,19 @@ class _TypingEllipsis: """Internal placeholder for ... (ellipsis).""" -_TYPING_INTERNALS = frozenset({ +_TYPING_INTERNALS = {{ '__parameters__', '__orig_bases__', '__orig_class__', '_is_protocol', '_is_runtime_protocol', '__protocol_attrs__', '__non_callable_proto_members__', '__type_params__', -}) +}} -_SPECIAL_NAMES = frozenset({ +_SPECIAL_NAMES = {{ '__abstractmethods__', '__annotations__', '__dict__', '__doc__', '__init__', '__module__', '__new__', '__slots__', '__subclasshook__', '__weakref__', '__class_getitem__', '__match_args__', '__static_attributes__', '__firstlineno__', '__annotate__', -}) +}} # These special attributes will be not collected as protocol members. EXCLUDED_ATTRIBUTES = _TYPING_INTERNALS | _SPECIAL_NAMES | {'_MutableMapping__marker'} @@ -2955,11 +2955,11 @@ def _make_nmtuple(name, types, module, defaults = ()): # attributes prohibited to set in NamedTuple class syntax -_prohibited = frozenset({'__new__', '__init__', '__slots__', '__getnewargs__', - '_fields', '_field_defaults', - '_make', '_replace', '_asdict', '_source'}) +_prohibited = {{'__new__', '__init__', '__slots__', '__getnewargs__', + '_fields', '_field_defaults', '_make', '_replace', '_asdict', + '_source'}} -_special = frozenset({'__module__', '__name__', '__annotations__'}) +_special = {{'__module__', '__name__', '__annotations__'}} class NamedTupleMeta(type): @@ -3749,7 +3749,7 @@ def get_protocol_members(tp: type, /) -> frozenset[str]: >>> class P(Protocol): ... def a(self) -> str: ... ... b: int - >>> get_protocol_members(P) == frozenset({'a', 'b'}) + >>> get_protocol_members(P) == {{'a', 'b'}} True Raise a TypeError for arguments that are not Protocols. diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 3ef83e263f53b7..81481fe235b066 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -1099,11 +1099,11 @@ def _calls_repr(self): # Denylist for forbidden attribute names in safe mode -_ATTRIB_DENY_LIST = frozenset({ +_ATTRIB_DENY_LIST = {{ name.removeprefix("assert_") for name in dir(NonCallableMock) if name.startswith("assert_") -}) +}} class _AnyComparer(list): diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py index fa69d5846f2fa7..2467bbd6fde42d 100644 --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -627,7 +627,7 @@ def main(args=None): 'to the latest version in PyPI') parser.add_argument('--without-scm-ignore-files', dest='scm_ignore_files', action='store_const', const=frozenset(), - default=frozenset(['git']), + default={{'git'}}, help='Skips adding SCM ignore files to the environment ' 'directory (Git is supported by default).') options = parser.parse_args(args)