packaging icon indicating copy to clipboard operation
packaging copied to clipboard

Allow modifying versions

Open hauntsaninja opened this issue 1 year ago • 4 comments

Fixes #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 since other parts don't get reset.
  • This is why I don't allow replacing epoch. One could make an argument that we shouldn't allow replacing release either, thoughts? (E.g. when would it make sense to replace the release but keep the pre?)
  • 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 avatar Jun 16 '23 23:06 hauntsaninja

The general approach looks okay to me (with Tzu-ping's comments). @pradyunsg ?

FYI I converted this to a draft until there are tests and documentation.

brettcannon avatar Jun 23 '23 23:06 brettcannon

@pradyunsg ?

Same. I'm on board for this approach, assuming tests + docs + existing review comments are addressed. :)

pradyunsg avatar Jul 09 '23 13:07 pradyunsg

Hello. If it is not intentional to keep props readonly why not just add setters for smooth increment? e.g.

a = Version('1.2.3')
a.minor += 1

doc-sheet avatar Jul 27 '23 15:07 doc-sheet

If it is not intentional to keep props readonly

Where do you get this impression?

uranusjr avatar Jul 28 '23 06:07 uranusjr