Skip to content

Commit 20ba785

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

File tree

6 files changed

+29
-11
lines changed

6 files changed

+29
-11
lines changed

mypyc/ir/rtypes.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,9 @@ def __hash__(self) -> int:
488488
)
489489

490490
# Python dict object.
491-
true_dict_rprimitive: Final = RPrimitive("builtins.dict[confirmed]", is_unboxed=False, is_refcounted=True)
491+
true_dict_rprimitive: Final = RPrimitive(
492+
"builtins.dict[confirmed]", is_unboxed=False, is_refcounted=True
493+
)
492494
"""A primitive for dicts that are confirmed to be actual instances of builtins.dict, not a subclass."""
493495

494496
# An instance of a subclass of dict.
@@ -604,7 +606,10 @@ def is_list_rprimitive(rtype: RType) -> bool:
604606

605607

606608
def is_dict_rprimitive(rtype: RType) -> bool:
607-
return isinstance(rtype, RPrimitive) and rtype.name in ("builtins.dict", "builtins.dict[confirmed]")
609+
return isinstance(rtype, RPrimitive) and rtype.name in (
610+
"builtins.dict",
611+
"builtins.dict[confirmed]",
612+
)
608613

609614

610615
def is_true_dict_rprimitive(rtype: RType) -> bool:

mypyc/irbuild/builder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@
124124
)
125125
from mypyc.irbuild.util import bytes_from_str, is_constant
126126
from mypyc.options import CompilerOptions
127-
from mypyc.primitives.dict_ops import dict_set_item_op, true_dict_get_item_op, true_dict_set_item_op
127+
from mypyc.primitives.dict_ops import (
128+
dict_set_item_op,
129+
true_dict_get_item_op,
130+
)
128131
from mypyc.primitives.generic_ops import iter_op, next_op, py_setattr_op
129132
from mypyc.primitives.list_ops import list_get_item_unsafe_op, list_pop_last, to_list
130133
from mypyc.primitives.misc_ops import check_unpack_count_op, get_module_dict_op, import_op

mypyc/irbuild/classdef.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ def allocate_class(builder: IRBuilder, cdef: ClassDef) -> Value:
480480

481481
# Add it to the dict
482482
builder.primitive_op(
483-
true_dict_set_item_op, [builder.load_globals_dict(), builder.load_str(cdef.name), tp], cdef.line
483+
true_dict_set_item_op,
484+
[builder.load_globals_dict(), builder.load_str(cdef.name), tp],
485+
cdef.line,
484486
)
485487

486488
return tp

mypyc/irbuild/for_helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,9 @@ def make_for_loop_generator(
421421
# Special case "for k in <dict>".
422422
expr_reg = builder.accept(expr)
423423
target_type = builder.get_dict_key_type(expr)
424-
for_loop_cls = ForTrueDictionaryKeys if is_true_dict_rprimitive(rtyp) else ForDictionaryKeys
424+
for_loop_cls = (
425+
ForTrueDictionaryKeys if is_true_dict_rprimitive(rtyp) else ForDictionaryKeys
426+
)
425427
for_dict = for_loop_cls(builder, index, body_block, loop_exit, line, nested)
426428
for_dict.init(expr_reg, target_type)
427429
return for_dict

mypyc/irbuild/function.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@
7676
)
7777
from mypyc.irbuild.generator import gen_generator_func, gen_generator_func_body
7878
from mypyc.irbuild.targets import AssignmentTarget
79-
from mypyc.primitives.dict_ops import dict_new_op, true_dict_get_method_with_none, true_dict_set_item_op
79+
from mypyc.primitives.dict_ops import (
80+
dict_new_op,
81+
true_dict_get_method_with_none,
82+
true_dict_set_item_op,
83+
)
8084
from mypyc.primitives.generic_ops import py_setattr_op
8185
from mypyc.primitives.misc_ops import register_function
8286
from mypyc.primitives.registry import builtin_names
@@ -800,7 +804,9 @@ def generate_singledispatch_dispatch_function(
800804
dispatch_func_obj, "dispatch_cache", true_dict_rprimitive, line
801805
)
802806
call_find_impl, use_cache, call_func = BasicBlock(), BasicBlock(), BasicBlock()
803-
get_result = builder.primitive_op(true_dict_get_method_with_none, [dispatch_cache, arg_type], line)
807+
get_result = builder.primitive_op(
808+
true_dict_get_method_with_none, [dispatch_cache, arg_type], line
809+
)
804810
is_not_none = builder.translate_is_op(get_result, builder.none_object(), "is not", line)
805811
impl_to_use = Register(object_rprimitive)
806812
builder.add_bool_branch(is_not_none, use_cache, call_find_impl)

mypyc/irbuild/ll_builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@
131131
dict_ssize_t_size_op,
132132
dict_update_in_display_op,
133133
true_dict_copy_op,
134-
true_dict_update_op,
135134
true_dict_ssize_t_size_op,
135+
true_dict_update_op,
136136
)
137137
from mypyc.primitives.exc_ops import err_occurred_op, keep_propagating_op
138138
from mypyc.primitives.float_ops import copysign_op, int_to_float_op
@@ -1667,14 +1667,14 @@ def make_dict(self, key_value_pairs: Sequence[DictEntry], line: int) -> Value:
16671667
if len(key_value_pairs) == 1 and is_true_dict_rprimitive(value):
16681668
# fast path for cases like `my_func(**dict(zip(iterable, other)))` and similar
16691669
return self.call_c(true_dict_copy_op, [value], line=line)
1670-
1670+
16711671
result = self._create_dict(keys, values, line)
1672-
1672+
16731673
if is_true_dict_rprimitive(value):
16741674
op = true_dict_update_op
16751675
else:
16761676
op = dict_update_in_display_op
1677-
1677+
16781678
self.call_c(op, [result, value], line=line)
16791679

16801680
if result is None:

0 commit comments

Comments
 (0)