Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: lpascal-ledger <[email protected]>
  • Loading branch information
bigspider and lpascal-ledger committed Dec 10, 2024
1 parent 6489700 commit 2d22ebe
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test_utils/musig2.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def __init__(self, key: KeyPlaceholder, tree=Optional[Tree]):
self.tree: Optional[Tree] = tree

@classmethod
def from_string(cls, input_string):
def from_string(cls, input_string: str) -> "TrDescriptorTemplate":
parser = cls.Parser(input_string.replace("/**", "/<0;1>/*"))
return parser.parse()

Expand All @@ -298,7 +298,7 @@ def __init__(self, input):
self.index = 0
self.length = len(input)

def parse(self):
def parse(self) -> "TrDescriptorTemplate":
if self.input.startswith('tr('):
self.consume('tr(')
key = self.parse_keyplaceholder()
Expand All @@ -312,7 +312,7 @@ def parse(self):
raise Exception(
"Syntax error: Input does not start with 'tr('")

def parse_keyplaceholder(self):
def parse_keyplaceholder(self) -> KeyPlaceholder:
if self.peek() == '@':
self.consume('@')
key_index = self.parse_num()
Expand Down Expand Up @@ -357,7 +357,7 @@ def parse_script(self) -> str:
self.index += 1
return self.input[start:self.index]

def parse_key_indexes(self):
def parse_key_indexes(self) -> List[int]:
nums = []
self.consume('@')
nums.append(self.parse_num())
Expand All @@ -366,13 +366,13 @@ def parse_key_indexes(self):
nums.append(self.parse_num())
return nums

def parse_num(self):
def parse_num(self) -> int:
start = self.index
while self.index < self.length and self.input[self.index].isdigit():
self.index += 1
return int(self.input[start:self.index])

def consume(self, char):
def consume(self, char: str) -> None:
if self.input[self.index:self.index+len(char)] == char:
self.index += len(char)
else:
Expand Down

0 comments on commit 2d22ebe

Please sign in to comment.