Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8287b4b

Browse filesBrowse files
committed
refactor!(url): pattern_defaults -> defaults
1 parent 543e609 commit 8287b4b
Copy full SHA for 8287b4b

File tree

Expand file treeCollapse file tree

4 files changed

+12
-12
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+12
-12
lines changed

‎src/libvcs/url/base.py

Copy file name to clipboardExpand all lines: src/libvcs/url/base.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Rule(SkipDefaultFieldsReprMixin):
3232
"""Human readable description"""
3333
pattern: Pattern[str]
3434
"""Regex pattern"""
35-
pattern_defaults: dict[str, str] = dataclasses.field(default_factory=dict)
35+
defaults: dict[str, str] = dataclasses.field(default_factory=dict)
3636
"""Is the match unambiguous with other VCS systems? e.g. git+ prefix"""
3737
is_explicit: bool = False
3838

@@ -88,7 +88,7 @@ def register(self, cls: Rule) -> None:
8888
... label = 'gh-prefix'
8989
... description ='Matches prefixes like github:org/repo'
9090
... pattern = r'^github:(?P<path>.*)$'
91-
... pattern_defaults = {
91+
... defaults = {
9292
... 'hostname': 'github.com',
9393
... 'scheme': 'https'
9494
... }
@@ -107,7 +107,7 @@ def register(self, cls: Rule) -> None:
107107
>>> GitHubURL.is_valid(url='github:vcs-python/libvcs', is_explicit=True)
108108
True
109109
110-
Notice how ``pattern_defaults`` neatly fills the values for us.
110+
Notice how ``defaults`` neatly fills the values for us.
111111
112112
>>> GitHubURL(url='github:vcs-python/libvcs')
113113
GitHubURL(url=github:vcs-python/libvcs,
@@ -137,7 +137,7 @@ def register(self, cls: Rule) -> None:
137137
... label = 'gl-prefix'
138138
... description ='Matches prefixes like gitlab:org/repo'
139139
... pattern = r'^gitlab:(?P<path>)'
140-
... pattern_defaults = {
140+
... defaults = {
141141
... 'hostname': 'gitlab.com',
142142
... 'scheme': 'https',
143143
... 'suffix': '.git'

‎src/libvcs/url/git.py

Copy file name to clipboardExpand all lines: src/libvcs/url/git.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
""",
8888
re.VERBOSE,
8989
),
90-
pattern_defaults={"username": "git"},
90+
defaults={"username": "git"},
9191
),
9292
# SCP-style URLs, e.g. git@
9393
]
@@ -275,9 +275,9 @@ def __post_init__(self) -> None:
275275
for k, v in groups.items():
276276
setattr(self, k, v)
277277

278-
for k, v in rule.pattern_defaults.items():
278+
for k, v in rule.defaults.items():
279279
if getattr(self, k, None) is None:
280-
setattr(self, k, rule.pattern_defaults[k])
280+
setattr(self, k, rule.defaults[k])
281281

282282
@classmethod
283283
def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
@@ -544,7 +544,7 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
544544
... re.VERBOSE,
545545
... ),
546546
... is_explicit=True,
547-
... pattern_defaults={
547+
... defaults={
548548
... 'hostname': 'github.com'
549549
... }
550550
... )

‎src/libvcs/url/hg.py

Copy file name to clipboardExpand all lines: src/libvcs/url/hg.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ def __post_init__(self) -> None:
189189
for k, v in groups.items():
190190
setattr(self, k, v)
191191

192-
for k, v in rule.pattern_defaults.items():
192+
for k, v in rule.defaults.items():
193193
if getattr(self, k, None) is None:
194-
setattr(self, k, rule.pattern_defaults[k])
194+
setattr(self, k, rule.defaults[k])
195195

196196
@classmethod
197197
def is_valid(cls, url: str, is_explicit: Optional[bool] = False) -> bool:

‎src/libvcs/url/svn.py

Copy file name to clipboardExpand all lines: src/libvcs/url/svn.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ def __post_init__(self) -> None:
183183
for k, v in groups.items():
184184
setattr(self, k, v)
185185

186-
for k, v in rule.pattern_defaults.items():
186+
for k, v in rule.defaults.items():
187187
if getattr(self, k, None) is None:
188-
setattr(self, k, rule.pattern_defaults[k])
188+
setattr(self, k, rule.defaults[k])
189189

190190
@classmethod
191191
def is_valid(cls, url: str, is_explicit: Optional[bool] = False) -> bool:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.