Skip to content

Commit 45496c7

Browse files
committed
Fix linter errors in asmap.py
This fixes a few (harmless) linter errors that occur while checking `asmap.py` in Bitcoin Core's python linter.
1 parent 38575e8 commit 45496c7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

asmap.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ class ASMap:
281281
def update(self, prefix: List[bool], asn: int) -> None:
282282
"""Update this ASMap object to map prefix to the specified asn."""
283283
assert asn == 0 or _CODER_ASN.can_encode(asn)
284+
284285
def recurse(node: List, offset: int) -> None:
285286
if offset == len(prefix):
286287
# Reached the end of prefix; overwrite this node.
@@ -346,6 +347,7 @@ def lookup(self, prefix: List[bool]) -> Optional[int]:
346347
def _to_entries_flat(self, fill: bool = False) -> List[ASNEntry]:
347348
"""Convert an ASMap object to a list of non-overlapping (prefix, asn) objects."""
348349
prefix : List[bool] = []
350+
349351
def recurse(node: List) -> List[ASNEntry]:
350352
ret = []
351353
if len(node) == 1:
@@ -367,6 +369,7 @@ def recurse(node: List) -> List[ASNEntry]:
367369
def _to_entries_minimal(self, fill: bool = False) -> List[ASNEntry]:
368370
"""Convert a trie to a minimal list of ASNEntry objects, exploiting overlap."""
369371
prefix : List[bool] = []
372+
370373
def recurse(node: List) -> (Tuple[Dict[Optional[int], List[ASNEntry]], bool]):
371374
if len(node) == 1 and node[0] == 0:
372375
return {None if fill else 0: []}, True
@@ -380,7 +383,7 @@ def recurse(node: List) -> (Tuple[Dict[Optional[int], List[ASNEntry]], bool]):
380383
prefix.pop()
381384
hole = not fill and (lhole or rhole)
382385
def candidate(ctx: Optional[int], res0: Optional[List[ASNEntry]],
383-
res1: Optional[List[ASNEntry]]):
386+
res1: Optional[List[ASNEntry]]):
384387
if res0 is not None and res1 is not None:
385388
if ctx not in ret or len(res0) + len(res1) < len(ret[ctx]):
386389
ret[ctx] = res0 + res1
@@ -468,11 +471,13 @@ def recurse(node: List) -> Tuple[Dict[Optional[int], _BinNode], bool]:
468471
left, lhole = recurse(node[0])
469472
right, rhole = recurse(node[1])
470473
hole = (lhole or rhole) and not fill
474+
471475
def candidate(ctx: Optional[int], arg1, arg2, func: Callable):
472476
if arg1 is not None and arg2 is not None:
473477
cand = func(arg1, arg2)
474478
if ctx not in ret or cand.size < ret[ctx].size:
475479
ret[ctx] = cand
480+
476481
for ctx in set(left) | set(right):
477482
candidate(ctx, left.get(ctx), right.get(ctx), _BinNode.make_branch)
478483
candidate(ctx, left.get(None), right.get(ctx), _BinNode.make_branch)
@@ -527,8 +532,8 @@ def to_binary(self, fill: bool = False) -> bytes:
527532
Returns:
528533
A bytes object with the encoding of this ASMap object.
529534
"""
530-
531535
bits: List[int] = []
536+
532537
def recurse(node: _BinNode) -> None:
533538
_CODER_INS.encode(node.ins.value, bits)
534539
if node.ins == _Instruction.RETURN:
@@ -635,6 +640,7 @@ def diff(self, other: ASMap) -> List[ASNDiff]:
635640
"""Compute the diff from self to other."""
636641
prefix: List[bool] = []
637642
ret: List[ASNDiff] = []
643+
638644
def recurse(old_node: List, new_node: List):
639645
if len(old_node) == 1 and len(new_node) == 1:
640646
if old_node[0] != new_node[0]:

0 commit comments

Comments
 (0)