Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fbedea5

Browse filesBrowse files
Fix typo and indent (#10995)
1 parent f1167bc commit fbedea5
Copy full SHA for fbedea5

File tree

Expand file treeCollapse file tree

8 files changed

+52
-56
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+52
-56
lines changed

‎mypyc/ir/class_ir.py

Copy file name to clipboardExpand all lines: mypyc/ir/class_ir.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# vtable.
1919
#
2020
# This makes multiple inheritance tricky, since obviously we cannot be
21-
# an extension of multiple parent classes. We solve this by requriing
21+
# an extension of multiple parent classes. We solve this by requiring
2222
# all but one parent to be "traits", which we can operate on in a
2323
# somewhat less efficient way. For each trait implemented by a class,
2424
# we generate a separate vtable for the methods in that trait.
@@ -240,7 +240,7 @@ def get_method(self, name: str) -> Optional[FuncIR]:
240240
return res[0] if res else None
241241

242242
def subclasses(self) -> Optional[Set['ClassIR']]:
243-
"""Return all subclassses of this class, both direct and indirect.
243+
"""Return all subclasses of this class, both direct and indirect.
244244
245245
Return None if it is impossible to identify all subclasses, for example
246246
because we are performing separate compilation.
@@ -266,7 +266,7 @@ def concrete_subclasses(self) -> Optional[List['ClassIR']]:
266266
return None
267267
concrete = {c for c in subs if not (c.is_trait or c.is_abstract)}
268268
# We place classes with no children first because they are more likely
269-
# to appear in various isinstance() checks. We then sort leafs by name
269+
# to appear in various isinstance() checks. We then sort leaves by name
270270
# to get stable order.
271271
return sorted(concrete, key=lambda c: (len(c.children or []), c.name))
272272

‎mypyc/ir/rtypes.py

Copy file name to clipboardExpand all lines: mypyc/ir/rtypes.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ def __hash__(self) -> int:
283283
if IS_32_BIT_PLATFORM:
284284
c_size_t_rprimitive = uint32_rprimitive
285285
c_pyssize_t_rprimitive = RPrimitive('native_int', is_unboxed=True, is_refcounted=False,
286-
ctype='int32_t', size=4)
286+
ctype='int32_t', size=4)
287287
else:
288288
c_size_t_rprimitive = uint64_rprimitive
289289
c_pyssize_t_rprimitive = RPrimitive('native_int', is_unboxed=True, is_refcounted=False,
290-
ctype='int64_t', size=8)
290+
ctype='int64_t', size=8)
291291

292292
# Low level pointer, represented as integer in C backends
293293
pointer_rprimitive: Final = RPrimitive("ptr", is_unboxed=True, is_refcounted=False, ctype="CPyPtr")

‎mypyc/irbuild/classdef.py

Copy file name to clipboardExpand all lines: mypyc/irbuild/classdef.py
+11-12Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def transform_class_def(builder: IRBuilder, cdef: ClassDef) -> None:
8383
# properties with both getters and setters in non_extension
8484
# classes not supported
8585
builder.error("Property setters not supported in non-extension classes",
86-
stmt.line)
86+
stmt.line)
8787
for item in stmt.items:
8888
with builder.catch_errors(stmt.line):
8989
transform_method(builder, cdef, non_ext, get_func_def(item))
@@ -104,7 +104,7 @@ def transform_class_def(builder: IRBuilder, cdef: ClassDef) -> None:
104104
lvalue = stmt.lvalues[0]
105105
if not isinstance(lvalue, NameExpr):
106106
builder.error("Only assignment to variables is supported in class bodies",
107-
stmt.line)
107+
stmt.line)
108108
continue
109109
# We want to collect class variables in a dictionary for both real
110110
# non-extension classes and fake dataclass ones.
@@ -167,10 +167,10 @@ def allocate_class(builder: IRBuilder, cdef: ClassDef) -> Value:
167167
tp_bases = builder.add(LoadErrorValue(object_rprimitive, is_borrowed=True))
168168
modname = builder.load_str(builder.module_name)
169169
template = builder.add(LoadStatic(object_rprimitive, cdef.name + "_template",
170-
builder.module_name, NAMESPACE_TYPE))
170+
builder.module_name, NAMESPACE_TYPE))
171171
# Create the class
172172
tp = builder.call_c(pytype_from_template_op,
173-
[template, tp_bases, modname], cdef.line)
173+
[template, tp_bases, modname], cdef.line)
174174
# Immediately fix up the trait vtables, before doing anything with the class.
175175
ir = builder.mapper.type_to_ir[cdef.info]
176176
if not ir.is_trait and not ir.builtin_base:
@@ -189,11 +189,10 @@ def allocate_class(builder: IRBuilder, cdef: ClassDef) -> Value:
189189

190190
# Add it to the dict
191191
builder.call_c(dict_set_item_op,
192-
[
193-
builder.load_globals_dict(),
192+
[builder.load_globals_dict(),
194193
builder.load_str(cdef.name),
195-
tp,
196-
], cdef.line)
194+
tp],
195+
cdef.line)
197196

198197
return tp
199198

@@ -290,8 +289,8 @@ def setup_non_ext_dict(builder: IRBuilder,
290289
"""
291290
# Check if the metaclass defines a __prepare__ method, and if so, call it.
292291
has_prepare = builder.call_c(py_hasattr_op,
293-
[metaclass,
294-
builder.load_str('__prepare__')], cdef.line)
292+
[metaclass,
293+
builder.load_str('__prepare__')], cdef.line)
295294

296295
non_ext_dict = Register(dict_rprimitive)
297296

@@ -512,8 +511,8 @@ def create_mypyc_attrs_tuple(builder: IRBuilder, ir: ClassIR, line: int) -> Valu
512511
def finish_non_ext_dict(builder: IRBuilder, non_ext: NonExtClassInfo, line: int) -> None:
513512
# Add __annotations__ to the class dict.
514513
builder.call_c(dict_set_item_op,
515-
[non_ext.dict, builder.load_str('__annotations__'),
516-
non_ext.anns], -1)
514+
[non_ext.dict, builder.load_str('__annotations__'),
515+
non_ext.anns], -1)
517516

518517
# We add a __doc__ attribute so if the non-extension class is decorated with the
519518
# dataclass decorator, dataclass will not try to look for __text_signature__.

‎mypyc/irbuild/env_class.py

Copy file name to clipboardExpand all lines: mypyc/irbuild/env_class.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def instantiate_env_class(builder: IRBuilder) -> Value:
7878
if builder.fn_info.is_nested:
7979
builder.fn_info.callable_class._curr_env_reg = curr_env_reg
8080
builder.add(SetAttr(curr_env_reg,
81-
ENV_ATTR_NAME,
82-
builder.fn_info.callable_class.prev_env_reg,
83-
builder.fn_info.fitem.line))
81+
ENV_ATTR_NAME,
82+
builder.fn_info.callable_class.prev_env_reg,
83+
builder.fn_info.fitem.line))
8484
else:
8585
builder.fn_info._curr_env_reg = curr_env_reg
8686

‎mypyc/irbuild/expression.py

Copy file name to clipboardExpand all lines: mypyc/irbuild/expression.py
+23-23Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def transform_member_expr(builder: IRBuilder, expr: MemberExpr) -> Value:
122122
if final is not None:
123123
fullname, final_var, native = final
124124
value = builder.emit_load_final(final_var, fullname, final_var.name, native,
125-
builder.types[expr], expr.line)
125+
builder.types[expr], expr.line)
126126
if value is not None:
127127
return value
128128

@@ -223,7 +223,7 @@ def translate_call(builder: IRBuilder, expr: CallExpr, callee: Expression) -> Va
223223
function = builder.accept(callee)
224224
args = [builder.accept(arg) for arg in expr.args]
225225
return builder.py_call(function, args, expr.line,
226-
arg_kinds=expr.arg_kinds, arg_names=expr.arg_names)
226+
arg_kinds=expr.arg_kinds, arg_names=expr.arg_names)
227227

228228

229229
def translate_refexpr_call(builder: IRBuilder, expr: CallExpr, callee: RefExpr) -> Value:
@@ -278,19 +278,19 @@ def translate_method_call(builder: IRBuilder, expr: CallExpr, callee: MemberExpr
278278
else:
279279
obj = builder.accept(callee.expr)
280280
return builder.gen_method_call(obj,
281-
callee.name,
282-
args,
283-
builder.node_type(expr),
284-
expr.line,
285-
expr.arg_kinds,
286-
expr.arg_names)
281+
callee.name,
282+
args,
283+
builder.node_type(expr),
284+
expr.line,
285+
expr.arg_kinds,
286+
expr.arg_names)
287287

288288
elif builder.is_module_member_expr(callee):
289289
# Fall back to a PyCall for non-native module calls
290290
function = builder.accept(callee)
291291
args = [builder.accept(arg) for arg in expr.args]
292292
return builder.py_call(function, args, expr.line,
293-
arg_kinds=expr.arg_kinds, arg_names=expr.arg_names)
293+
arg_kinds=expr.arg_kinds, arg_names=expr.arg_names)
294294
else:
295295
receiver_typ = builder.node_type(callee.expr)
296296

@@ -305,12 +305,12 @@ def translate_method_call(builder: IRBuilder, expr: CallExpr, callee: MemberExpr
305305
obj = builder.accept(callee.expr)
306306
args = [builder.accept(arg) for arg in expr.args]
307307
return builder.gen_method_call(obj,
308-
callee.name,
309-
args,
310-
builder.node_type(expr),
311-
expr.line,
312-
expr.arg_kinds,
313-
expr.arg_names)
308+
callee.name,
309+
args,
310+
builder.node_type(expr),
311+
expr.line,
312+
expr.arg_kinds,
313+
expr.arg_names)
314314

315315

316316
def translate_super_method_call(builder: IRBuilder, expr: CallExpr, callee: SuperExpr) -> Value:
@@ -452,7 +452,7 @@ def try_gen_slice_op(builder: IRBuilder, base: Value, index: SliceExpr) -> Optio
452452

453453

454454
def transform_conditional_expr(builder: IRBuilder, expr: ConditionalExpr) -> Value:
455-
if_body, else_body, next = BasicBlock(), BasicBlock(), BasicBlock()
455+
if_body, else_body, next_block = BasicBlock(), BasicBlock(), BasicBlock()
456456

457457
builder.process_conditional(expr.cond, if_body, else_body)
458458
expr_type = builder.node_type(expr)
@@ -463,15 +463,15 @@ def transform_conditional_expr(builder: IRBuilder, expr: ConditionalExpr) -> Val
463463
true_value = builder.accept(expr.if_expr)
464464
true_value = builder.coerce(true_value, expr_type, expr.line)
465465
builder.add(Assign(target, true_value))
466-
builder.goto(next)
466+
builder.goto(next_block)
467467

468468
builder.activate_block(else_body)
469469
false_value = builder.accept(expr.else_expr)
470470
false_value = builder.coerce(false_value, expr_type, expr.line)
471471
builder.add(Assign(target, false_value))
472-
builder.goto(next)
472+
builder.goto(next_block)
473473

474-
builder.activate_block(next)
474+
builder.activate_block(next_block)
475475

476476
return target
477477

@@ -536,14 +536,14 @@ def transform_comparison_expr(builder: IRBuilder, e: ComparisonExpr) -> Value:
536536
# assuming that prev contains the value of `ei`.
537537
def go(i: int, prev: Value) -> Value:
538538
if i == len(e.operators) - 1:
539-
return transform_basic_comparison(builder,
540-
e.operators[i], prev, builder.accept(e.operands[i + 1]), e.line)
539+
return transform_basic_comparison(
540+
builder, e.operators[i], prev, builder.accept(e.operands[i + 1]), e.line)
541541

542542
next = builder.accept(e.operands[i + 1])
543543
return builder.builder.shortcircuit_helper(
544544
'and', expr_type,
545-
lambda: transform_basic_comparison(builder,
546-
e.operators[i], prev, next, e.line),
545+
lambda: transform_basic_comparison(
546+
builder, e.operators[i], prev, next, e.line),
547547
lambda: go(i + 1, next),
548548
e.line)
549549

‎mypyc/irbuild/function.py

Copy file name to clipboardExpand all lines: mypyc/irbuild/function.py
+6-10Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def transform_decorator(builder: IRBuilder, dec: Decorator) -> None:
109109
if decorated_func is not None:
110110
# Set the callable object representing the decorated function as a global.
111111
builder.call_c(dict_set_item_op,
112-
[builder.load_globals_dict(),
113-
builder.load_str(dec.func.name), decorated_func],
114-
decorated_func.line)
112+
[builder.load_globals_dict(),
113+
builder.load_str(dec.func.name), decorated_func],
114+
decorated_func.line)
115115

116116
maybe_insert_into_registry_dict(builder, dec.func)
117117

@@ -336,7 +336,7 @@ def c() -> None:
336336
dispatch_name = decorator_helper_name(name) if is_decorated else name
337337
return gen_dispatch_func_ir(builder, fitem, fn_info.name, dispatch_name, sig)
338338

339-
return (func_ir, func_reg)
339+
return func_ir, func_reg
340340

341341

342342
def gen_func_ir(builder: IRBuilder,
@@ -396,12 +396,8 @@ def handle_ext_method(builder: IRBuilder, cdef: ClassDef, fdef: FuncDef) -> None
396396
# Set the callable object representing the decorated method as an attribute of the
397397
# extension class.
398398
builder.call_c(py_setattr_op,
399-
[
400-
typ,
401-
builder.load_str(name),
402-
decorated_func
403-
],
404-
fdef.line)
399+
[typ, builder.load_str(name), decorated_func],
400+
fdef.line)
405401

406402
if fdef.is_property:
407403
# If there is a property setter, it will be processed after the getter,

‎mypyc/irbuild/prepare.py

Copy file name to clipboardExpand all lines: mypyc/irbuild/prepare.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ def can_subclass_builtin(builtin_base: str) -> bool:
164164
# BaseException and dict are special cased.
165165
return builtin_base in (
166166
('builtins.Exception', 'builtins.LookupError', 'builtins.IndexError',
167-
'builtins.Warning', 'builtins.UserWarning', 'builtins.ValueError',
168-
'builtins.object', ))
167+
'builtins.Warning', 'builtins.UserWarning', 'builtins.ValueError',
168+
'builtins.object', ))
169169

170170

171171
def prepare_class_def(path: str, module_name: str, cdef: ClassDef,

‎mypyc/irbuild/vtable.py

Copy file name to clipboardExpand all lines: mypyc/irbuild/vtable.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
def compute_vtable(cls: ClassIR) -> None:
1010
"""Compute the vtable structure for a class."""
11-
if cls.vtable is not None: return
11+
if cls.vtable is not None:
12+
return
1213

1314
if not cls.is_generated:
1415
cls.has_dict = any(x.inherits_python for x in cls.mro)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.