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

Modifying versions #659

Open
hauntsaninja opened this issue Jan 12, 2023 · 2 comments · May be fixed by #698
Open

Modifying versions #659

hauntsaninja opened this issue Jan 12, 2023 · 2 comments · May be fixed by #698

Comments

@hauntsaninja
Copy link
Contributor

hauntsaninja commented Jan 12, 2023

I've sometimes had occasion to want to modify a version, for instance, to add or remove a local or dev version component. It would be nice to have a replace method that creates a copy of a Version with the changes you want.

I'm happy to open a PR!

@pradyunsg
Copy link
Member

A PR would be welcome! :)

@lhd-biosency
Copy link

I have the same need to increment a version

hauntsaninja added a commit to hauntsaninja/packaging that referenced this issue Jun 16, 2023
Fixes pypa#659

Let me know if something like this seems acceptable to you and I'll add
tests and documentation.

Some notes:
- My use case was adding a local version to an existing version
- I don't think it would make sense to allow replacing parts of the
  release, e.g. "major", since I don't really see a use case. Things
  like `v.replace(major=v.major+1)` are probably just mistakes.
- This is why I don't allow replacing `epoch` either
- `Version.__new__(Version)` is a little gross, as is the munging.
  The munging is designed to line up with the corresponding properties,
  so `v.replace(xyz=v.xyz)` always works.
@hauntsaninja hauntsaninja linked a pull request Jun 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants