Skip to content
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

♻️ Remove incremental #627

Merged
merged 15 commits into from
Jul 30, 2024
Merged

Conversation

sigma67
Copy link
Contributor

@sigma67 sigma67 commented Jul 28, 2024

Description

Fixes #308

This removes the dependency on incremental on towncrier itself, while keeping support for detecting incremental version in projects for which towncrier is used to build the release notes.

Checklist

  • Make sure changes are covered by existing or new tests.
  • For at least one Python version, make sure local test run is green.
  • Create a file in src/towncrier/newsfragments/. Describe your
    change and include important information. Your change will be included in the public release notes.
  • Make sure all GitHub Actions checks are green (they are automatically checking all of the above).
  • Ensure docs/tutorial.rst is still up-to-date.
  • If you add new CLI arguments (or change the meaning of existing ones), make sure docs/cli.rst reflects those changes.
  • If you add new configuration options (or change the meaning of existing ones), make sure docs/configuration.rst reflects those changes.

@sigma67 sigma67 requested a review from a team as a code owner July 28, 2024 09:33
@sigma67 sigma67 force-pushed the remove-incremental branch from a037030 to dd20edf Compare July 28, 2024 09:51
@sigma67 sigma67 mentioned this pull request Jul 28, 2024
7 tasks
Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for picking up on this.

I just did a quick review before approving the CI run.

I have not yet fully reviewed the automated tests.

RELEASE.rst Outdated
@@ -19,9 +19,9 @@ The same branch is used for the release candidated and the final release.
In the end, the release branch is merged into the main branch.

Update the version to the release candidate with the first being ``rc1`` (as opposed to 0).
In ``src/towncrier/_version.py`` the version is set using ``incremental`` such as::
In ``pyproject.toml`` the version is set like::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping that we can set the version in single place, like src/towncrier/_version.py and the build system can automatically extract the version from there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in doc were recycled but now they are no longer relevant. Reverted

docs/conf.py Outdated
@@ -29,13 +29,13 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
import importlib.metadata as importlib_metadata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use from towncrier import __verison__ or something similar ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in doc were recycled but now they are no longer relevant. Reverted

raise Exception(
f"No __version__ or metadata version info for the '{package}' package."
)
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I this change needed ?

I was thinking that this was sorted out in #502

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think it's just a merge artifact. Reverted

import click

from ._version import __version__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep the import ?

It's just that now __version__ will be a simple text.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done



class TestPackaging(TestCase):
def test_version_warning(self):
def test_version_attr(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why this change is needed.

The previous test look good enough to me. :)

I am misssing something ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous test was checking for the presence of an Incremental Version object (which obviously no longer exists in towncrier)

I've replaced it with a test to assert that a DeprecationWarning is present

Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes.
They look good.

I left a few minor comments.

In order to merge this, the mypy checks must pass.

Also the coverage must pass

src/towncrier/_project.py      52      1     18      1    97%   90, 104->exit

version = getattr(module, "__version__", None)
# Incremental has support for package names, try duck-typing it.
with contextlib.suppress(AttributeError):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we are missing a brach test here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Copy link
Member

@adiroiban adiroiban Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see this error reported

line 104 didn't return from function 'get_project_name' because the return on line 105 wasn't executed

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The miss indicator was a bit confusing for me, should be gone now hopefully

version = str(version.base()).strip()
# Incremental uses `X.Y.rcN`.
# Standardize on importlib (and PEP440) use of `X.YrcN`:
return version.replace(".rc", "rc") # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why coverage is reporting this line as not covered.... we need to check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an indentation problem with a test, fixed now

Copy link
Contributor Author

@sigma67 sigma67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, mypy and coverage should be passing now

version = getattr(module, "__version__", None)
# Incremental has support for package names, try duck-typing it.
with contextlib.suppress(AttributeError):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added



class TestPackaging(TestCase):
def test_version_warning(self):
def test_version_attr(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous test was checking for the presence of an Incremental Version object (which obviously no longer exists in towncrier)

I've replaced it with a test to assert that a DeprecationWarning is present

version = str(version.base()).strip()
# Incremental uses `X.Y.rcN`.
# Standardize on importlib (and PEP440) use of `X.YrcN`:
return version.replace(".rc", "rc") # type: ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an indentation problem with a test, fixed now

@sigma67
Copy link
Contributor Author

sigma67 commented Jul 29, 2024

@adiroiban just to know a timeline, is there any ETA on the next release that could include this change?

This is just a question, no pressure

@adiroiban
Copy link
Member

We can do a release.
There is already a ticket for that here #616

the important part is to have someone who cares for a new release and has some time to test the release

@adiroiban
Copy link
Member

Thanks for fixing all the checks.

As part of this PR we need to update the RELEASE.rst ... if we just merge, the information for RELEASE.rst will no longer be valid

I now see that RELEASE.rst changes were removed from this PR

https://github.com/twisted/towncrier/pull/491/files#diff-0a92214d83ea13ad864f4b1d6c0b5703956cf4bd927c116e75f68d4048e0744f


My hope was that with this PR we can have pyproject.toml with

[metadata]
version = attr: towncrier.__version__

@adiroiban
Copy link
Member

I made a few small changes to the PR description... the important one is linking to the issue, so that when we merge this PR, the issue is automatically closed.

@sigma67
Copy link
Contributor Author

sigma67 commented Jul 29, 2024

Ok, I'm a bit confused admittedly because in the prior MR it was stated explicitly to keep the version file.

Here: #491 (comment)

If we still want to move to pyproject.toml I'd prefer to do that in a separate MR.

What do you want changed in RELEASE.rst ? Should I update the version as well or is that done by the release manager?

@adiroiban
Copy link
Member

adiroiban commented Jul 29, 2024

Right now the content of the RELEASE.rst is

towncrier/RELEASE.rst

Lines 21 to 24 in 4b58be5

Update the version to the release candidate with the first being ``rc1`` (as opposed to 0).
In ``src/towncrier/_version.py`` the version is set using ``incremental`` such as::
__version__ = Version('towncrier', 19, 9, 0, release_candidate=1)


I think it should change to

 Update the version to the release candidate with the first being ``rc1`` (as opposed to 0). 
 In ``src/towncrier/_version.py`` the version is set using PEP440 a compliant string, such as:: 
  
     __version__ = "24.7.0rc1" 

This revert is not quite OK 2cf4e76

Instead of updating the pyproject.toml we update the _version.py file.

We no longer want to use incremental . This is why towncrier own development documentation should no longer instruct developers to use incremental


But I understand your concern.

The question is where to store the version:

  • pyproject.toml
  • src/towncrier/_version.py
  • src/towncier/__init__.py

Since the version was already stored in src/towncrier/_version.py , my suggestion for this PR is to continue to store it there.

In a separate PR we can consider moving it inside pyproject.toml or somewhere else.

@sigma67
Copy link
Contributor Author

sigma67 commented Jul 29, 2024

Ok my bad, I guess it only needed some changes instead of a revert. RELEASE.rst is updated.

Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for the update.


I did a few change to release.rst

There was a section underline mismatch ... so I start doing the edit and then I realized that 19.9.0 is a better example as it shows that we don't add leasing 0 in the version ... but we use ISO date format with leading zero.

@adiroiban
Copy link
Member

I have enabled auto-merge on this.

and once this is merge I plan to do a new release.

Thanks again.

I am very happy to see that we no longer use incremental.

@adiroiban adiroiban enabled auto-merge (squash) July 30, 2024 10:40
@adiroiban adiroiban merged commit 0fa7b48 into twisted:trunk Jul 30, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove dependency on incremental in favor of general compatible solution
4 participants