Skip to content

Provide Public API to normalize version parts #1067

Closed

Description

@notatallshaw

As we push users to only use public APIs in packaging one thing I notice is that hatch needs to use the private function _parse_letter_version: https://github.com/pypa/hatch/blob/hatchling-v1.28.0/backend/src/hatchling/version/scheme/standard.py#L98

This is actually reasonable that project management utilities would want to be able to normalize part of a version such as the pre or post-release part without needing or wanting to construct a whole version.

It is even useful for interacting with the __replace__ API which currently only takes the normalized pre-release parts, so you need to normalize them before passing them in.

I have not thought out what a good public API would look like, we could simply make private functions public, or there may be a better approach.

Activity

  1. henryiii commented on Jan 23, 2026

    @henryiii
    Contributor

    Would it make sense to either have .replace, which is .__replace__ but with added normalization, or even add normalization to .__replace__, and provide .replace_unchecked (or something like that) if we need a fast path? The normalization might be pretty light weight?

  2. notatallshaw commented on Jan 24, 2026

    @notatallshaw
    MemberAuthor

    If that would remove the need to call _parse_letter_version directly, sure.

    When I first opened the PR for replace I was intentionally limited on normalization until there was a required use case, but perhaps this is that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions