-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Improve python version formatting 🐍 affects [pypi piwheels github] #7682
Conversation
|
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.
Looks good to me. 👍🏻 Interestingly , @paulmelnikow intended on using pep440 in #5592 as well.
return { | ||
label: dependency, | ||
message: version ? addv(version) : ref, | ||
color: 'blue', | ||
color: version ? pep440VersionColor(version) : 'blue', | ||
} |
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.
Could we use renderVersionBadge
here, either with a conditional or ternary operator? For example:
return version ? renderVersionBadge({ version, versionFormatter: pep440VersionColor })
: { label: dependency, message: ref, color: 'blue' }
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.
We'd have to extend renderVersionBadge()
to also take a custom label. For this badge the label is the name of the locked dependency. Tbh I'm inclined to leave it
59da343
to
cd0095f
Compare
I've rebased this to resolve the conflicts on package.json and package-lock.json as it was easier than doing it as a merge. No functional changes |
After implementing the piwheels badge the other day I realised that I had just used
renderVersionBadge()
but our standard version formattershields/services/color-formatters.js
Lines 16 to 20 in 76a64a7
isn't great for python packages because it will format something like
2.0.0rc1
or2.0.0b2
as "stable".Then I started pulling the thread and realised this problem actually also applies to some other python ecosystem badges.
so in this PR I have:
pep440VersionColor()
formatter function which uses https://github.com/renovatebot/pep440 to parse versionsrenderVersionBadge()
a custom formatter function as an optional param - this might be handy if we want to use a custom formatter for other package ecosystems.