Skip to content

Commit 6c1242a

Browse files
committed
fix(parser,base,git): More fixes for matchers
1 parent 55878c5 commit 6c1242a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

libvcs/parse/base.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def register(self, cls: Matcher) -> None:
4343
4444
.. currentmodule:: libvcs.parse.git
4545
46+
>>> from dataclasses import dataclass
4647
>>> from libvcs.parse.git import GitURL, GitBaseURL
4748
4849
:class:`GitBaseURL` - the ``git(1)`` compliant parser - won't accept a pip-style URL:
@@ -71,8 +72,9 @@ def register(self, cls: Matcher) -> None:
7172
... 'scheme': 'https'
7273
... }
7374
74-
>>> class GitHubLocation(GitURL):
75-
... matchers = MatcherRegistry = MatcherRegistry(
75+
>>> @dataclasses.dataclass(repr=False)
76+
... class GitHubLocation(GitURL):
77+
... matchers: MatcherRegistry = MatcherRegistry(
7678
... _matchers={'github_prefix': GitHubPrefix}
7779
... )
7880
@@ -94,10 +96,11 @@ def register(self, cls: Matcher) -> None:
9496
9597
Option 1: Create a brand new matcher
9698
97-
>>> class GitLabLocation(GitURL):
98-
... matchers = MatcherRegistry = MatcherRegistry(
99-
... _matchers={'gitlab_prefix': GitLabPrefix}
100-
... )
99+
>>> @dataclasses.dataclass(repr=False)
100+
... class GitLabLocation(GitURL):
101+
... matchers: MatcherRegistry = MatcherRegistry(
102+
... _matchers={'gitlab_prefix': GitLabPrefix}
103+
... )
101104
102105
>>> GitLabLocation.is_valid(url='gitlab:vcs-python/libvcs')
103106
True
@@ -122,7 +125,8 @@ def register(self, cls: Matcher) -> None:
122125
123126
>>> from libvcs.parse.git import DEFAULT_MATCHERS, PIP_DEFAULT_MATCHERS
124127
125-
>>> class GitURLWithPip(GitBaseURL):
128+
>>> @dataclasses.dataclass(repr=False)
129+
... class GitURLWithPip(GitBaseURL):
126130
... matchers: MatcherRegistry = MatcherRegistry(
127131
... _matchers={m.label: m for m in [*DEFAULT_MATCHERS, *PIP_DEFAULT_MATCHERS]}
128132
... )

0 commit comments

Comments
 (0)