-
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
make UnparsedVersion.__lt__ order-agnostic #8559
Conversation
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #8559 +/- ##
=======================================
Coverage 86.37% 86.37%
=======================================
Files 174 174
Lines 25587 25582 -5
=======================================
- Hits 22100 22096 -4
+ Misses 3487 3486 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
acc761e
to
b6f9298
Compare
(cherry picked from commit 89f20d1)
resolves #8571
docs dbt-labs/docs.getdbt.com/#
Problem
The current implementation of UnparsedVersion.__lt__ is sensitive to the order of arguments, leading to surprising behaviour such as:
The root cause is that UnparsedVersion.lt first attempts to cast
self.v
toother
's type in order to do the comparison, and if that fails then attempts to castother.v
toself
type. This means that casting may work in some directions but not others and result in different comparison methods (e.g. numeric vs alphabetic) depending on which input isself
and which isother
.Solution
UnparsedVersion.v
is eitherfloat
orstr
. Simplify the lt implementation to just try to cast both inputs to floats and do a numeric comparison, falling back tostr
if this is not posssible -- making the method insensitive to order but more tightly coupled to the type ofUnparsedVersion.v
Checklist