Skip to content

Commit 03e2ccb

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b03b6b6 commit 03e2ccb

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

mypyc/codegen/literals.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
# Supported Python literal types. All tuple / frozenset / dict items must have supported
77
# literal types as well, but we can't represent the type precisely.
88
LiteralValue = Union[
9-
str, bytes, int, bool, float, complex, tuple[object, ...], frozenset[object], dict[object, object], None
9+
str,
10+
bytes,
11+
int,
12+
bool,
13+
float,
14+
complex,
15+
tuple[object, ...],
16+
frozenset[object],
17+
dict[object, object],
18+
None,
1019
]
1120

1221

@@ -124,7 +133,7 @@ def literal_index(self, value: LiteralValue) -> int:
124133
def make_dict_literal_key(self, value: dict) -> tuple:
125134
"""Make a unique key for a literal dict."""
126135
return tuple(value.items())
127-
136+
128137
def num_literals(self) -> int:
129138
# The first three are for None, True and False
130139
return (

mypyc/irbuild/expression.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@
5959
BasicBlock,
6060
Call,
6161
ComparisonOp,
62-
InitStatic,
6362
Integer,
6463
LoadAddress,
6564
LoadLiteral,
66-
LoadStatic,
6765
PrimitiveDescription,
6866
RaiseStandardError,
6967
Register,
@@ -103,7 +101,12 @@
103101
)
104102
from mypyc.irbuild.specialize import apply_function_specialization, apply_method_specialization
105103
from mypyc.primitives.bytes_ops import bytes_slice_op
106-
from mypyc.primitives.dict_ops import dict_get_item_op, dict_new_op, dict_set_item_op, dict_template_copy_op, exact_dict_set_item_op
104+
from mypyc.primitives.dict_ops import (
105+
dict_get_item_op,
106+
dict_new_op,
107+
dict_template_copy_op,
108+
exact_dict_set_item_op,
109+
)
107110
from mypyc.primitives.generic_ops import iter_op, name_op
108111
from mypyc.primitives.list_ops import list_append_op, list_extend_op, list_slice_op
109112
from mypyc.primitives.misc_ops import ellipsis_op, get_module_dict_op, new_slice_op, type_op
@@ -1012,7 +1015,9 @@ def _visit_tuple_display(builder: IRBuilder, expr: TupleExpr) -> Value:
10121015
return builder.primitive_op(list_tuple_op, [val_as_list], expr.line)
10131016

10141017

1015-
def dict_literal_values(builder: IRBuilder, items: Sequence[tuple[Expression | None, Expression]], line: int) -> "dict | None":
1018+
def dict_literal_values(
1019+
builder: IRBuilder, items: Sequence[tuple[Expression | None, Expression]], line: int
1020+
) -> dict | None:
10161021
"""Try to extract a constant dict from a dict literal, recursively staticizing nested dicts.
10171022
10181023
If all keys and values are deeply immutable and constant (including nested dicts as values),
@@ -1043,6 +1048,7 @@ def dict_literal_values(builder: IRBuilder, items: Sequence[tuple[Expression | N
10431048

10441049
return result or None
10451050

1051+
10461052
def transform_dict_expr(builder: IRBuilder, expr: DictExpr) -> Value:
10471053
"""First accepts all keys and values, then makes a dict out of them.
10481054

mypyc/test-data/irbuild-dict.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,4 +603,3 @@ L0:
603603
r5 = CPyDict_Build(1, r0, r4)
604604
d = r5
605605
return 1
606-

0 commit comments

Comments
 (0)