Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit d9ca33f

Browse files
committed
typehints
1 parent eb9554f commit d9ca33f

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/newick.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ def _iter_properties(c):
7777
yield k, v
7878

7979

80-
def length_parser(x):
80+
def length_parser(x: str) -> float:
8181
return float(x or 0.0)
8282

8383

84-
def length_formatter(x):
84+
def length_formatter(x: float) -> str:
8585
return '%s' % x
8686

8787

@@ -90,7 +90,7 @@ def check_string(n, type_):
9090
raise ValueError('"{}" may not appear in {}'.format(RESERVED_PUNCTUATION.keys(), type_))
9191

9292

93-
class Node(object):
93+
class Node:
9494
"""
9595
A Node may be a tree, a subtree or a leaf.
9696
@@ -126,14 +126,14 @@ def __init__(self,
126126
self.length = length
127127

128128
@property
129-
def properties(self):
129+
def properties(self) -> dict:
130130
res = {}
131131
for comment in self.comments:
132132
res.update(list(_iter_properties(comment)))
133133
return res
134134

135135
@property
136-
def name(self):
136+
def name(self) -> str:
137137
return self._name
138138

139139
@name.setter
@@ -153,7 +153,7 @@ def __repr__(self):
153153
return 'Node("%s")' % self.name
154154

155155
@property
156-
def unquoted_name(self):
156+
def unquoted_name(self) -> str:
157157
n = self.name
158158
if n and n.startswith(QUOTE) and n.endswith(QUOTE):
159159
n = n[1:-1]
@@ -184,7 +184,7 @@ def create(cls, **kw) -> 'Node': # Backwards compatibility.
184184
return cls(**kw)
185185

186186
@property
187-
def descendants(self):
187+
def descendants(self) -> typing.Iterable['Node']:
188188
return self._descendants
189189

190190
@descendants.setter

0 commit comments

Comments
 (0)