File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import dataclasses
2- from typing import Iterator , Pattern , Protocol
2+ from typing import Iterator , Optional , Pattern , Protocol
33
44from libvcs ._internal .dataclasses import SkipDefaultFieldsReprMixin
55
@@ -13,7 +13,7 @@ def __init__(self, url: str):
1313 def to_url (self ) -> str :
1414 ...
1515
16- def is_valid (self , url : str ) -> bool :
16+ def is_valid (self , url : str , is_explicit : Optional [ bool ] = None ) -> bool :
1717 ...
1818
1919
Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ def __post_init__(self):
278278 setattr (self , k , v )
279279
280280 @classmethod
281- def is_valid (cls , url : str ) -> bool :
281+ def is_valid (cls , url : str , is_explicit : Optional [ bool ] = None ) -> bool :
282282 """Whether URL is compatible with VCS or not.
283283
284284 Examples
@@ -293,6 +293,12 @@ def is_valid(cls, url: str) -> bool:
293293 >>> GitURL.is_valid(url='notaurl')
294294 False
295295 """
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+ )
296302 return any (re .search (matcher .pattern , url ) for matcher in cls .matchers .values ())
297303
298304 def to_url (self ) -> str :
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ def __post_init__(self):
195195 setattr (self , k , v )
196196
197197 @classmethod
198- def is_valid (cls , url : str ) -> bool :
198+ def is_valid (cls , url : str , is_explicit : Optional [ bool ] = False ) -> bool :
199199 """Whether URL is compatible with VCS or not.
200200
201201 Examples
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ def __post_init__(self):
189189 setattr (self , k , v )
190190
191191 @classmethod
192- def is_valid (cls , url : str ) -> bool :
192+ def is_valid (cls , url : str , is_explicit : Optional [ bool ] = False ) -> bool :
193193 """Whether URL is compatible with VCS or not.
194194
195195 Examples
You can’t perform that action at this time.
0 commit comments