Skip to content

Commit 7eadc11

Browse files
committed
Some type hints and name improvements
1 parent 74fa52d commit 7eadc11

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

dpath/segments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def leaves(obj):
140140
return filter(lambda p: leafy(p[1]), walk(obj))
141141

142142

143-
def int_str(segment):
143+
def int_str(segment: PathSegment) -> PathSegment:
144144
"""
145145
If the segment is an integer, return the string conversion.
146146
Otherwise return the segment unchanged. The conversion uses 'str'.
@@ -163,7 +163,7 @@ class Star(object):
163163
STAR = Star()
164164

165165

166-
def match(segments, glob):
166+
def match(segments: Sequence[PathSegment], glob: Sequence[str]):
167167
"""
168168
Return True if the segments match the given glob, otherwise False.
169169

dpath/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def search(obj: Dict, glob: str, yielded=False, separator="/", afilter: Filter =
230230
every element in the document that matched the glob.
231231
"""
232232

233-
globlist = _split_path(glob, separator)
233+
split_glob = _split_path(glob, separator)
234234

235235
def keeper(path, found):
236236
"""
@@ -240,7 +240,7 @@ def keeper(path, found):
240240
if not dirs and not segments.leaf(found):
241241
return False
242242

243-
matched = segments.match(path, globlist)
243+
matched = segments.match(path, split_glob)
244244
selected = afilter and afilter(found)
245245

246246
return (matched and not afilter) or (matched and selected)

0 commit comments

Comments
 (0)