Skip to content

Commit ad9a6b3

Browse files
committed
Merge pull request #391 from ivuk/pep8-fixes
PEP 8 fixes
2 parents 3ba926c + 5d563ff commit ad9a6b3

File tree

3 files changed

+179
-180
lines changed

3 files changed

+179
-180
lines changed

mypy/build.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444

4545

4646
# Build flags
47-
COMPILE_ONLY = 'compile-only' # Compile only to C, do not generate binary
48-
VERBOSE = 'verbose' # More verbose messages (for troubleshooting)
49-
MODULE = 'module' # Build/run module as a script
50-
TEST_BUILTINS = 'test-builtins' # Use stub builtins to speed up tests
47+
COMPILE_ONLY = 'compile-only' # Compile only to C, do not generate binary
48+
VERBOSE = 'verbose' # More verbose messages (for troubleshooting)
49+
MODULE = 'module' # Build/run module as a script
50+
TEST_BUILTINS = 'test-builtins' # Use stub builtins to speed up tests
5151

5252

5353
# State ids. These describe the states a source file / module can be in a
@@ -325,7 +325,7 @@ def __init__(self, data_dir: str,
325325
self.states = List[State]()
326326
self.module_files = Dict[str, str]()
327327
self.icode = Dict[str, FuncIcode]()
328-
self.binary_path = None # type: str
328+
self.binary_path = None # type: str
329329
self.module_deps = Dict[Tuple[str, str], bool]()
330330
self.missing_modules = Set[str]()
331331

@@ -505,7 +505,7 @@ def final_passes(self, files: List[MypyFile],
505505
self.generate_icode(files, types)
506506
self.generate_c_and_compile(files)
507507
elif self.target in [SEMANTIC_ANALYSIS, TYPE_CHECK]:
508-
pass # Nothing to do.
508+
pass # Nothing to do.
509509
else:
510510
raise RuntimeError('Unsupported target %d' % self.target)
511511

@@ -563,10 +563,10 @@ def generate_c_and_compile(self, files: List[MypyFile]) -> None:
563563
vm_dir = os.path.join(data_dir, 'vm')
564564
cc = os.getenv('CC', 'gcc')
565565
cflags = shlex.split(os.getenv('CFLAGS', '-O2'))
566-
cmdline = [cc] + cflags +['-I%s' % vm_dir,
567-
'-o%s' % program_name,
568-
c_file,
569-
os.path.join(vm_dir, 'runtime.c')]
566+
cmdline = [cc] + cflags + ['-I%s' % vm_dir,
567+
'-o%s' % program_name,
568+
c_file,
569+
os.path.join(vm_dir, 'runtime.c')]
570570
self.log(' '.join(cmdline))
571571
status = subprocess.call(cmdline)
572572
# TODO check status
@@ -675,7 +675,7 @@ def is_ready(self) -> bool:
675675

676676
def num_incomplete_deps(self) -> int:
677677
"""Return the number of dependencies that are ready but incomplete."""
678-
return 0 # Does not matter in this state
678+
return 0 # Does not matter in this state
679679

680680
def state(self) -> int:
681681
raise RuntimeError('Not implemented')
@@ -964,7 +964,7 @@ def verify_module(id: str, path: str) -> bool:
964964
def super_packages(id: str) -> List[str]:
965965
"""Return the surrounding packages of a module, e.g. ['os'] for os.path."""
966966
c = id.split('.')
967-
res = [] # type: List[str]
967+
res = [] # type: List[str]
968968
for i in range(1, len(c)):
969969
res.append('.'.join(c[:i]))
970970
return res

mypy/cgen.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@
3838

3939
class CGenerator:
4040
"""Translate icode to C."""
41-
41+
4242
func = Undefined(FuncIcode)
4343

4444
def __init__(self) -> None:
4545
self.prolog = ['#include "mypy.h"\n']
46-
self.types = [] # type: List[str]
47-
self.out = [] # type: List[str]
46+
self.types = [] # type: List[str]
47+
self.out = [] # type: List[str]
4848
self.indent = 0
4949
self.frame_size = 0
50-
self.global_vars = {} # type: Dict[str, int]
51-
self.classes = {} # type: Dict[TypeInfo, ClassRepresentation]
50+
self.global_vars = {} # type: Dict[str, int]
51+
self.classes = {} # type: Dict[TypeInfo, ClassRepresentation]
5252
# Count temp labels.
5353
self.num_labels = 0
5454

@@ -60,7 +60,7 @@ def output(self) -> List[str]:
6060
result.extend(self.out)
6161
result.append(MAIN_FRAGMENT)
6262
return result
63-
63+
6464
def generate_function(self, name: str, func: FuncIcode) -> None:
6565
# Initialize function-specific state information.
6666
self.func = func
@@ -70,7 +70,7 @@ def generate_function(self, name: str, func: FuncIcode) -> None:
7070
# Simplistic name mangling.
7171
name = name.replace('.', '_')
7272
name = name.replace('$', '_')
73-
73+
7474
# Add function definition and opening brace.
7575
header = 'MValue %s(MEnv *e)' % name
7676
self.emit(header)
@@ -84,9 +84,9 @@ def generate_function(self, name: str, func: FuncIcode) -> None:
8484
self.emit('MValue *frame = e->frame;')
8585
self.emit('e->frame = frame + %d;' % self.frame_size)
8686
self.emit('if (e->frame >= e->stack_top)')
87-
self.emit(' abort();') # Dummy handler; should raise an exception
87+
self.emit(' abort();') # Dummy handler; should raise an exception
8888

89-
# Geneate code that initializes the stack frame. The gc must not see
89+
# Generate code that initializes the stack frame. The gc must not see
9090
# uninitialized values.
9191
for i in range(func.num_args, self.frame_size):
9292
if func.register_types[i] == icode.INT:
@@ -183,12 +183,12 @@ def opcode(self, opcode: BinOp) -> None:
183183
# Overflow check needs third argument (operation result).
184184
label = self.label()
185185
self.emit('if (MIsShort(%s) && MIsShort(%s)) {' % (left, right))
186-
self.emit( 't = %s;' % operation)
187-
self.emit( 'if (%s(t, %s, %s))' % (overflow, left, right))
188-
self.emit( ' goto %s;' % label)
186+
self.emit(' t = %s;' % operation)
187+
self.emit(' if (%s(t, %s, %s))' % (overflow, left, right))
188+
self.emit(' goto %s;' % label)
189189
self.emit('} else {')
190190
self.emit('%s:' % label)
191-
self.emit( 't = %s(e, %s, %s);' % (opfn, left, right))
191+
self.emit(' t = %s(e, %s, %s);' % (opfn, left, right))
192192
self.emit_error_check('t')
193193
self.emit('}')
194194
self.emit('%s = t;' % target)
@@ -198,15 +198,15 @@ def opcode(self, opcode: BinOp) -> None:
198198
(left, right, overflow, left, right))
199199
self.emit(' %s = %s;' % (target, operation))
200200
self.emit('else {')
201-
self.emit( '%s = %s(e, %s, %s);' % (target, opfn, left, right))
201+
self.emit(' %s = %s(e, %s, %s);' % (target, opfn, left, right))
202202
self.emit_error_check(target)
203203
self.emit('}')
204204
else:
205205
# No overflow check needed.
206206
self.emit('if (MIsShort(%s) && MIsShort(%s))' % (left, right))
207207
self.emit(' %s = %s;' % (target, operation))
208208
self.emit('else {')
209-
self.emit( '%s = %s(e, %s, %s);' % (target, opfn, left, right))
209+
self.emit(' %s = %s(e, %s, %s);' % (target, opfn, left, right))
210210
self.emit_error_check(target)
211211
self.emit('}')
212212

@@ -255,7 +255,7 @@ def opcode(self, opcode: CallMethod) -> None:
255255
target = reg(opcode.target)
256256
self.get_class_representation(opcode.type)
257257
rep = self.classes[opcode.type]
258-
method = opcode.method.replace('$', '_') # Simple name mangling.
258+
method = opcode.method.replace('$', '_') # Simple name mangling.
259259
if opcode.static:
260260
self.direct_call(opcode.target, '%s_%s' % (opcode.type.name(),
261261
method))
@@ -325,7 +325,7 @@ def generate_class(self, cls: TypeInfo) -> 'ClassRepresentation':
325325
self.emit_types(' 0,')
326326
self.emit_types(' "%s"' % cls.fullname())
327327
self.emit_types('};\n')
328-
328+
329329
return rep
330330

331331
def direct_call(self, target: int, funcname: str) -> None:
@@ -394,14 +394,14 @@ class ClassRepresentation:
394394

395395
cname = ''
396396
fullname = ''
397-
397+
398398
slotmap = Undefined(Dict[str, int])
399-
399+
400400
# Map method name to/from vtable index
401401
vtable_index = Undefined(Dict[str, int])
402-
402+
403403
defining_class = Undefined(Dict[str, str])
404-
404+
405405
vtable_methods = Undefined(List[str])
406406

407407
def __init__(self, type: TypeInfo, base: 'ClassRepresentation') -> None:
@@ -418,8 +418,8 @@ def __init__(self, type: TypeInfo, base: 'ClassRepresentation') -> None:
418418
self.add_method(m, type)
419419
else:
420420
self.slotmap[m] = len(self.slotmap)
421-
self.add_method('_' + m, type) # Getter TODO refactor
422-
self.add_method('set_' + m, type) # Setter # TODO refactor
421+
self.add_method('_' + m, type) # Getter TODO refactor
422+
self.add_method('set_' + m, type) # Setter # TODO refactor
423423

424424
def add_method(self, method: str, defining_class: TypeInfo) -> None:
425425
self.defining_class[method] = defining_class.name()

0 commit comments

Comments
 (0)