Skip to content

Commit 42ad0a1

Browse files
committed
Remove unnecessary negative number check
1 parent cb6b94b commit 42ad0a1

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

dpath/segments.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,12 @@ def match(segments: Path, glob: Glob):
232232
# If search path segment (s) is an int and the current evaluated index (g) is int-like,
233233
# then g is surely a sequence index as well. Convert it to int and compare.
234234
if isinstance(s, int) and isinstance(g, str):
235-
neg_c = g.count("-")
236-
237-
if (neg_c == 0 and g.isdigit()) or (neg_c == 1 and g.lstrip("-").isdigit()):
238-
return s == int(g)
235+
return s == int(g)
236+
except:
237+
# Will reach this point if g can't be converted to an int...
238+
pass
239239

240+
try:
240241
# Let's see if the glob matches. We will turn any kind of
241242
# exception while attempting to match into a False for the
242243
# match.

0 commit comments

Comments
 (0)