Skip to content

Commit c32735a

Browse files
committed
linter changes
1 parent cb229b8 commit c32735a

File tree

9 files changed

+26
-23
lines changed

9 files changed

+26
-23
lines changed

lib/rust/scalgoproto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl<'a> Reader<'a> {
211211

212212
pub fn get_ptr(&self, offset: usize) -> Result<Option<(usize, u32, usize)>> {
213213
let o = match self.get_48_usize(offset)? {
214-
Some(v) if v == 0 => return Ok(None),
214+
Some(0) => return Ok(None),
215215
Some(v) => v,
216216
None => return Ok(None),
217217
};

scalgoprotoc/annotate.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def assign_magic(self, node: Table, required: bool) -> None:
173173
self.error(node.token, "Magic required in none inline context")
174174
else:
175175
node.magic = int(self.value(node.id_)[1:], 16)
176-
if not 1 <= node.magic < 2 ** 32:
176+
if not 1 <= node.magic < 2**32:
177177
self.error(node.id_, "Magic outside range")
178178

179179
def visit_content(
@@ -368,10 +368,10 @@ def visit_content(
368368
if v.inplace:
369369
self.error(v.inplace, "Basic types may not be inplace")
370370
if v.type_.type == TokenType.U16:
371-
v.parsed_value = self.get_int(v.value, 0, 2 ** 16 - 1, 0)
371+
v.parsed_value = self.get_int(v.value, 0, 2**16 - 1, 0)
372372
default.append(struct.pack("<H", v.parsed_value))
373373
elif v.type_.type == TokenType.I16:
374-
v.parsed_value = self.get_int(v.value, -(2 ** 15), 2 ** 15 - 1, 0)
374+
v.parsed_value = self.get_int(v.value, -(2**15), 2**15 - 1, 0)
375375
default.append(struct.pack("<h", v.parsed_value))
376376
else:
377377
self.error(v.type_, "Internal error")
@@ -381,10 +381,10 @@ def visit_content(
381381
if v.inplace:
382382
self.error(v.inplace, "Basic types may not be inplace")
383383
if v.type_.type == TokenType.UI32:
384-
v.parsed_value = self.get_int(v.value, 0, 2 ** 32 - 1, 0)
384+
v.parsed_value = self.get_int(v.value, 0, 2**32 - 1, 0)
385385
default.append(struct.pack("<I", v.parsed_value))
386386
elif v.type_.type == TokenType.I32:
387-
v.parsed_value = self.get_int(v.value, -(2 ** 31), 2 ** 31 - 1, 0)
387+
v.parsed_value = self.get_int(v.value, -(2**31), 2**31 - 1, 0)
388388
default.append(struct.pack("<i", v.parsed_value))
389389
elif v.type_.type == TokenType.F32:
390390
v.parsed_value = self.get_float(
@@ -399,10 +399,10 @@ def visit_content(
399399
if v.inplace:
400400
self.error(v.inplace, "Basic types may not be inplace")
401401
if v.type_.type == TokenType.UI64:
402-
v.parsed_value = self.get_int(v.value, 0, 2 ** 64 - 1, 0)
402+
v.parsed_value = self.get_int(v.value, 0, 2**64 - 1, 0)
403403
default.append(struct.pack("<Q", v.parsed_value))
404404
elif v.type_.type == TokenType.I64:
405-
v.parsed_value = self.get_int(v.value, -(2 ** 64), 2 ** 64 - 1, 0)
405+
v.parsed_value = self.get_int(v.value, -(2**64), 2**64 - 1, 0)
406406
default.append(struct.pack("<q", v.parsed_value))
407407
elif v.type_.type == TokenType.F64:
408408
v.parsed_value = self.get_float(

scalgoprotoc/cpp_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ def generate_union(self, union: Union) -> None:
893893
% self.qualify(union, True)
894894
)
895895
self.o("")
896-
for (inplace, prefix) in ((False, ""), (True, "Inplace")):
896+
for inplace, prefix in ((False, ""), (True, "Inplace")):
897897
self.switch_namespace(union.namespace)
898898
self.o(
899899
"class %s%sOut: public scalgoproto::%sUnionOut {"

scalgoprotoc/magic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def run(args) -> int:
99
rng = random.SystemRandom()
1010
for x in range(10):
11-
print("@%08X" % rng.randint(0, 2 ** 32))
11+
print("@%08X" % rng.randint(0, 2**32))
1212
return 0
1313

1414

scalgoprotoc/python_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ def generate(self, ast: List[AstNode]) -> None:
13101310
else:
13111311
raise ICE()
13121312

1313-
for (d, imp) in imports.items():
1313+
for d, imp in imports.items():
13141314
doc = self.documents.by_id[d]
13151315
self.o(
13161316
"from %s%s import %s" % (self.import_prefix, doc.name, ", ".join(imp))

scalgoprotoc/rust_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@ def generate(self, ast: List[AstNode]) -> None:
15811581
else:
15821582
raise ICE()
15831583

1584-
for (d, imp) in imports.items():
1584+
for d, imp in imports.items():
15851585
doc = self.documents.by_id[d]
15861586
for ii in imp:
15871587
self.o(f"use crate::{doc.name}::{ii};")

scalgoprotoc/ts_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ def generate(self, ast: List[AstNode]) -> None:
11441144
else:
11451145
raise ICE()
11461146

1147-
for (d, imp) in imports.items():
1147+
for d, imp in imports.items():
11481148
doc = self.documents.by_id[d]
11491149
self.o("import {%s} from '%s'" % (", ".join(imp), doc.name))
11501150

scalgoprotoc/validate.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ def ov(t: Token) -> str:
7676
]
7777

7878
def check_flag(
79-
om: Value, nm: Value, ov: Optional[Token], nv: Optional[Token], flag: str
79+
om: Value,
80+
nm: Value,
81+
ov: Optional[Token],
82+
nv: Optional[Token],
83+
flag: str,
8084
) -> None:
8185
nonlocal ok
8286
if (ov is None) == (nv is None):
@@ -137,7 +141,6 @@ def check_members(
137141
allow_append: bool = True,
138142
check_types: bool = True,
139143
) -> None:
140-
141144
nonlocal ok
142145

143146
# Matchup old and new names
@@ -146,7 +149,7 @@ def check_members(
146149
m: List[List[int]] = [[0 for _ in range(len(s2) + 1)]]
147150
for i1, v1 in enumerate(s1):
148151
m.append([0])
149-
for (i2, v2) in enumerate(s2):
152+
for i2, v2 in enumerate(s2):
150153
m[i1 + 1].append(
151154
m[i1][i2]
152155
if v1 == v2
@@ -190,7 +193,7 @@ def check_members(
190193
new_members_indexes = dict(
191194
[(nv(nm.identifier), i) for (i, nm) in enumerate(new_members)]
192195
)
193-
for (om, nm) in mismatches:
196+
for om, nm in mismatches:
194197
oname = ov(om.identifier) if om else None
195198
nname = nv(nm.identifier) if nm else None
196199
if (
@@ -279,7 +282,7 @@ def check_members(
279282
ok = False
280283

281284
if check_types:
282-
for (om, nm) in matches:
285+
for om, nm in matches:
283286
match_value(om, nm)
284287

285288
def match_structs(old: AstNode, new: Struct) -> None:

test/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,17 @@ def main():
178178
os.mkdir("tmp")
179179

180180
# Test names
181-
for (bad, good) in (("monkey", "Monkey"), ("Monkey_Cat", "MonkeyCat")):
181+
for bad, good in (("monkey", "Monkey"), ("Monkey_Cat", "MonkeyCat")):
182182
runNeg("bad table name %s" % bad, "table %s @8908828A {}", bad, good)
183-
for (bad, good) in (("Cat", "cat"), ("type", "myType"), ("cat_dog", "catDog")):
183+
for bad, good in (("Cat", "cat"), ("type", "myType"), ("cat_dog", "catDog")):
184184
runNeg(
185185
"bad table member name %s" % bad,
186186
"table Monkey @8908828A {%s : U32}",
187187
bad,
188188
good,
189189
)
190190
# Test table types
191-
for (bad, good) in (
191+
for bad, good in (
192192
("Int", "I32"),
193193
("int32", "I32"),
194194
("bool", "Bool"),
@@ -204,7 +204,7 @@ def main():
204204
)
205205

206206
# Test struct types
207-
for (bad, good) in (
207+
for bad, good in (
208208
("optional U32", "U32"),
209209
("U64 = 7", "U64"),
210210
("list Bool", "Bool"),
@@ -215,7 +215,7 @@ def main():
215215
runNeg("bad struct member type %s" % bad, "struct Monkey {a: %s}", bad, good)
216216

217217
# Test table id
218-
for (bad, good) in (
218+
for bad, good in (
219219
("0x1234567", "@8908828A"),
220220
("@8908828X", "@8908828A"),
221221
("@8908828a", "@8908828A"),

0 commit comments

Comments
 (0)