File tree Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 1
1
import dataclasses
2
- from typing import Iterator , Pattern , Protocol
2
+ from typing import Iterator , Optional , Pattern , Protocol
3
3
4
4
from libvcs ._internal .dataclasses import SkipDefaultFieldsReprMixin
5
5
@@ -13,7 +13,7 @@ def __init__(self, url: str):
13
13
def to_url (self ) -> str :
14
14
...
15
15
16
- def is_valid (self , url : str ) -> bool :
16
+ def is_valid (self , url : str , is_explicit : Optional [ bool ] = None ) -> bool :
17
17
...
18
18
19
19
Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ def __post_init__(self):
278
278
setattr (self , k , v )
279
279
280
280
@classmethod
281
- def is_valid (cls , url : str ) -> bool :
281
+ def is_valid (cls , url : str , is_explicit : Optional [ bool ] = None ) -> bool :
282
282
"""Whether URL is compatible with VCS or not.
283
283
284
284
Examples
@@ -293,6 +293,12 @@ def is_valid(cls, url: str) -> bool:
293
293
>>> GitURL.is_valid(url='notaurl')
294
294
False
295
295
"""
296
+ if is_explicit is not None :
297
+ return any (
298
+ re .search (matcher .pattern , url )
299
+ for matcher in cls .matchers .values ()
300
+ if matcher .is_explicit == is_explicit
301
+ )
296
302
return any (re .search (matcher .pattern , url ) for matcher in cls .matchers .values ())
297
303
298
304
def to_url (self ) -> str :
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ def __post_init__(self):
195
195
setattr (self , k , v )
196
196
197
197
@classmethod
198
- def is_valid (cls , url : str ) -> bool :
198
+ def is_valid (cls , url : str , is_explicit : Optional [ bool ] = False ) -> bool :
199
199
"""Whether URL is compatible with VCS or not.
200
200
201
201
Examples
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ def __post_init__(self):
189
189
setattr (self , k , v )
190
190
191
191
@classmethod
192
- def is_valid (cls , url : str ) -> bool :
192
+ def is_valid (cls , url : str , is_explicit : Optional [ bool ] = False ) -> bool :
193
193
"""Whether URL is compatible with VCS or not.
194
194
195
195
Examples
You can’t perform that action at this time.
0 commit comments