packaging icon indicating copy to clipboard operation
packaging copied to clipboard

Refactor canonicalize_version

Open jaraco opened this issue 1 year ago • 0 comments

In reviewing the behavior of canonicalize_version, I found the documentation and implementation to be somewhat lacking in context. The docstring alluded to a difference but didn't indicate what the difference was exactly. By comparing it with Version.__str__, one could see that the bulk of the function was a copy/paste, but there was one bit accounting for the altered release behavior. This approach now shares the same implementation of the Version.__str__ and also takes advantage of singledispatch to separate the two forms for better separation. It also takes the opportunity to document the behaviors more fully.

  • In canonicalize_version, re-use Version.str.
  • Utilize singledispatch to separate concerns in canonicalize_version.

jaraco avatar Apr 13 '24 16:04 jaraco