-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feature/deps-regex-semver #5370
feature/deps-regex-semver #5370
Conversation
core/dbt/semver.py
Outdated
@@ -95,7 +95,7 @@ def from_version_string(cls, version_string): | |||
|
|||
if not match: | |||
raise dbt.exceptions.SemverException( | |||
'Could not parse version "{}"'.format(version_string) | |||
'"{}" is not a valid semantic version.'.format(version_string) |
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.
'"{}" is not a valid semantic version.'.format(version_string) | |
f'"{version_string}" is not a valid semantic version.' |
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.
Added this change in the most recent commit. Thanks!
core/dbt/semver.py
Outdated
@@ -427,6 +427,15 @@ def resolve_to_specific_version(requested_range, available_versions): | |||
return max_version_string | |||
|
|||
|
|||
def semver_regex_versioning(versions: List[str]) -> bool: |
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.
Is this just for testing? Can we move it into the test file if that's the case?
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 is just for testing the various version types. I moved it into the testing file as that does make a lot more sense 😄
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.
LGTM! Thanks @fivetran-joemarkiewicz for the contribution 🎉
* feature/deps-regex-semver * pre-commit fixes * applying review updates
resolves #5201
Description
In this PR I incorporate the suggested regular expression (RegEx) to check a SemVer string for when
dbt deps
is invoked. Truth be told, when breaking out this expression, there wasn't too much difference from what was included previously. Please let me know if I missed anything.In addition to the above, I updated the error that is shown when the versioning does not fit within the new regex rules. This error message will be descriptive to show users that the version most likely needs to be modified.
Finally, I added unit testing to ensure all variations of the valid versions shown here are truly valid, and that all variations of the invalid versions shown here are truly invalid. Please note, I ended up creating a new function to simply test if the version triggered the error message upon invoking the
from_version_string
function. Please let me know if this was not needed and there was just a unit test I was simply missing! This is my first attempt at unit tests so happy to modify where needed! 😄CLI Output
Based off these changes, if the version provided for a package does not match the regex rules then we should see a clearer error. See below for my validation of the error message
Checklist
☝️ I don't think this is needed, but please let me know and I can if that is required.
changie new
to create a changelog entry