-
-
Notifications
You must be signed in to change notification settings - Fork 281
Feature: version schemes endpoint #733
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
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #733 +/- ##
==========================================
+ Coverage 97.31% 97.47% +0.16%
==========================================
Files 42 42
Lines 2045 2061 +16
==========================================
+ Hits 1990 2009 +19
+ Misses 55 52 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
a65da14
to
b4b9716
Compare
This looks really cool. I really like using the proper name: "scheme". My main concern is that this a big breaking change, right? I already migrated a lot of projects to
I also think using |
b4b9716
to
55f470a
Compare
OK, I rebased and squash the PR, taking every remark into account (this includes the deprecation warnings). Note: I wonder if exposing this as a cli parameter ( |
396dcdd
to
ac5f873
Compare
Looks really good, sorry for the delay. I will take a deeper look when i'm back from holidays (June). Thanks a lot 🚀 |
This is fantastic! I am interested in delving into it further in the upcoming weeks. I have been extremely busy this year and feeling a bit overwhelmed but will try my best to help! |
DEFAULT_VERSION_PARSER = r"v?(?P<version>([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?(\w+)?)" | ||
|
||
|
||
class VersionProtocol(Protocol): |
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.
I was thinking the VersionProvider(ABC)
is an ABC
instead of Protocol
, should we stick to ABC for consistency? Or change VersionProvider
to a Protocol
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.
btw how does ABC
work with type inference? I'd like to have something that can type hint (this helps during development if you use mypy or similar), and that can also fail at runtime if not implemented 🤔 (this for those who don't use any kind of tpye hinting)
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 need a compromise here:
ABC
forces you into inheritance, which is defeating protocol purpose (especially Feature: version schemes endpoint #733 (comment)) and it would forcePep440
andSemVer
into multiple inheritanceProtocol
is the opposite, it forces into nothing because by default it is ignored at runtime
However, there is one possibility which is interesting: we can make the protocol runtime checkable and raise a warning or fail when calling get_version_scheme
, something like:
scheme = ep.load()
if not isinstance(scheme, VersionProtocol)
warnings.warn(f"{name} is not implementing the Version protocol")
return scheme
This way we would have best of both world:
- clean type hinting
- freedom of implementation
- runtime error or warning for devs not using MyPy
What do you thing of this solution ?
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.
I think it's great. I would also like to choose one between protocol and ABC. Do we need then to keep versionProvider
as an ABC
? or can we migrate (at some point in the future) to Protocol with runtime check?
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.
OK, it has been added in the latest push (with some tests)
I think there is nothing preventing from switching between ABC
and Protocol
. In both cases, this is a design choice, the same as above 👆🏼
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.
Totally, I just think we should stick to one for plugins, to reduce cognitive load on those who will implement them.
This looks awesome, I think it's ready to be merged (besides my comment). Thanks @noirbizarre |
…me` endpoint. Refactors `version_types` (which is now deprecated) into `version_schemes`, exposes them through a `commitizen.scheme` entrypoint and ensure it encapsulates all the versionning logic for parsing and bumping.
ac5f873
to
49572ab
Compare
PR updated with the protocol runtime check and the associated tests 👍🏼 |
Sorry for the delay, I'm a bit slow, this looks good to me, shall we merge? |
@woile Yep, let's merge it 💪 I think I'll have some time to take a look this holiday. I'll point out and maybe try to address if I found anything. Thanks! |
Description
This PR is a continuation of #686 following this comment.
It does the following:
version_type
intoscheme
to follow specifications semantic (PEP 440, SemVer but also CalVer which are all using thescheme
term)commitizen.scheme
endpoint for version scheme pluginsbump
to the plugin allowing support for all commitizen feature (especially incremental versioning which is relying on the ability to parse version as well as bumping which should be able to generate the next version according to the scheme)This PR is also related to #645 as the incremental feature requires both the template and the version knowledge to be complete (aka. one of the 2 PR should be rebased after the merge of the other to properly handle this part)
Checklist
./scripts/format
and./scripts/test
locally to ensure this change passes linter check and test