-
-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be nicer about possible misconfigurations #1004
base: main
Are you sure you want to change the base?
Changes from all commits
263dc5b
4497912
90810a3
d9b4d24
cdcc699
5f20c3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,9 +41,9 @@ def _check_tag_regex(value: str | Pattern[str] | None) -> Pattern[str]: | |
|
||
group_names = regex.groupindex.keys() | ||
if regex.groups == 0 or (regex.groups > 1 and "version" not in group_names): | ||
warnings.warn( | ||
"Expected tag_regex to contain a single match group or a group named" | ||
" 'version' to identify the version part of any tag." | ||
raise ValueError( | ||
f"Expected tag_regex '{regex.pattern}' to contain a single match group or" | ||
" a group named 'version' to identify the version part of any tag." | ||
) | ||
|
||
return regex | ||
|
@@ -105,6 +105,9 @@ class Configuration: | |
|
||
parent: _t.PathT | None = None | ||
|
||
def __post_init__(self) -> None: | ||
self.tag_regex = _check_tag_regex(self.tag_regex) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. taking this here without leaving it in place creates potental trouble for valies valid in config but not in the config objects |
||
|
||
@property | ||
def absolute_root(self) -> str: | ||
return _check_absolute_root(self.root, self.relative_to) | ||
|
@@ -139,13 +142,11 @@ def from_data( | |
given configuration data | ||
create a config instance after validating tag regex/version class | ||
""" | ||
tag_regex = _check_tag_regex(data.pop("tag_regex", None)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this check needs to say even if the validation gets more struct |
||
version_cls = _validate_version_cls( | ||
data.pop("version_cls", None), data.pop("normalize", True) | ||
) | ||
return cls( | ||
relative_to, | ||
version_cls=version_cls, | ||
tag_regex=tag_regex, | ||
**data, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is possibly a breaking change im not sure we can integrate it off hand