-
Notifications
You must be signed in to change notification settings - Fork 122
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
move version into pyproject.toml #640
Conversation
@adiroiban as requested this is the separate PR to move the version into I suggest we also remove the deprecated |
4d97dd5
to
b1f92e7
Compare
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.
Thanks. It looks very good.
Just a comment regarding _get_metadata_version
and the removal information should have a separate fragment.
Other than that, all good.
Thanks again
src/towncrier/_project.py
Outdated
@@ -67,6 +69,10 @@ def get_version(package_dir: str, package: str) -> str: | |||
if version := _get_metadata_version(package): | |||
return version | |||
|
|||
with contextlib.suppress(PackageNotFoundError): |
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.
Do we need this code?
What does it to, on top of the existing _get_metadata_version
?
Maybe move this to _get_metadata_version
If this needs to stay here, then it needs a comment to explain why _get_metadata_version
is not good enough here and why we get the version again via `importlib.metadata.
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.
The test test_version_from_metadata
will fail without this code.
The existing function _get_metadata_version_
uses importlib.metadata.packages_distributions
, which seems to not contain towncrier at test runtime. Not sure why, but I also don't know why this method of getting the version is used instead of straight up passing package
to importlib.metadata.version
.
I can move the check into the function, maybe inside the if not distribution_names
block. Not sure.
What do you think?
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 that _get_metadata_version
should do everything.
So the code should be moved there.
Maybe also remove importlib.metadata.packages_distributions
and replace it with the current method.
Do we need both methods? Just asking.
I am not very familiar with the importlib
API ... but as long as the tests pass, we should be ok.
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, I thought there might be some reason why it was done this way.
I replaced it as you suggested.
Co-authored-by: Adi Roiban <adiroiban@gmail.com>
src/towncrier/newsfragments/640.misc
Outdated
@@ -0,0 +1,4 @@ | |||
Moved towncrier version definition from src/towncrier/_version.py to pyproject.toml | |||
|
|||
towncrier.__version__ was removed, after being deprecated in 23.6.0. |
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.
these 2 lines needs to be in a separate newsfragment file of type .removal
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.
done
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.
Thanks for the cleanup.
We should not worry about keeping "zombie" code.
If we think that some part of the code is not needed, we should just delete it.
As long as the tests still pass, it should be ok.
Description
Fixes #<!-- add the associated GitHub Issue ID>
Checklist
src/towncrier/newsfragments/
. Briefly describe yourchanges, with information useful to end users. Your change will be included in the public release notes.
docs/tutorial.rst
is still up-to-date.docs/cli.rst
reflects those changes.docs/configuration.rst
reflects those changes.