@@ -102,12 +102,10 @@ def levenshtein(source: str, target: str) -> int:
102
102
103
103
104
104
class DocoptLanguageError (Exception ):
105
-
106
105
"""Error in construction of usage-message by developer."""
107
106
108
107
109
108
class DocoptExit (SystemExit ):
110
-
111
109
"""Exit in case user invoked program with incorrect arguments."""
112
110
113
111
usage = ""
@@ -168,7 +166,6 @@ def transform(pattern: "BranchPattern") -> "Either":
168
166
169
167
170
168
class LeafPattern (Pattern ):
171
-
172
169
"""Leaf/terminal node of a pattern tree."""
173
170
174
171
def __repr__ (self ) -> str :
@@ -190,29 +187,28 @@ def match(
190
187
return False , left , collected
191
188
left_ = left [:pos ] + left [(pos + 1 ) :]
192
189
same_name = [a for a in collected if a .name == self .name ]
193
- if type (self .value ) == int and len (same_name ) > 0 :
190
+ if isinstance (self .value , int ) == int and len (same_name ) > 0 :
194
191
if isinstance (same_name [0 ].value , int ):
195
192
same_name [0 ].value += 1
196
193
return True , left_ , collected
197
- if type (self .value ) == int and not same_name :
194
+ if isinstance (self .value , int ) and not same_name :
198
195
match .value = 1
199
196
return True , left_ , collected + [match ]
200
- if same_name and type (self .value ) == list :
201
- if type (match .value ) == str :
197
+ if same_name and isinstance (self .value , list ) :
198
+ if isinstance (match .value , str ) :
202
199
increment = [match .value ]
203
200
if same_name [0 ].value is not None and increment is not None :
204
201
if isinstance (same_name [0 ].value , type (increment )):
205
202
same_name [0 ].value += increment
206
203
return True , left_ , collected
207
- elif not same_name and type (self .value ) == list :
204
+ elif not same_name and isinstance (self .value , list ) :
208
205
if isinstance (match .value , str ):
209
206
match .value = [match .value ]
210
207
return True , left_ , collected + [match ]
211
208
return True , left_ , collected + [match ]
212
209
213
210
214
211
class BranchPattern (Pattern ):
215
-
216
212
"""Branch/inner node of a pattern tree."""
217
213
218
214
def __init__ (self , * children ) -> None :
@@ -347,7 +343,6 @@ def match(self, left: List["Pattern"], collected: List["Pattern"] = None) -> Any
347
343
348
344
349
345
class OptionsShortcut (NotRequired ):
350
-
351
346
"""Marker/placeholder for [options] shortcut."""
352
347
353
348
0 commit comments