Skip to content

Level-shaped helper on Score answers #1

Open

Description

@VianneyMI

Context

Score.score is TypeSafe's expected level: a probability-weighted average that can fall between two levels (e.g. 1.47). Callers who want a level often recompute the most likely one from probabilities:

level = max(answer.probabilities, key=answer.probabilities.__getitem__)  # Urgency.THIS_WEEK

Deferred during the design of 0.1.0 under "keep TypeSafe names; add aliases or helpers only if they prove worth it".

Goal

Spare callers that recomputation when they want a level rather than an expected value.

Scope

  • A helper on Score answers returning the most likely level as a member of the declared Levels type.

Design considerations

  • Name. The package keeps TypeSafe's names for fields (score, confidence, probabilities). A helper is an addition and needs a name that reads apart from TypeSafe's fields (most_likely_level, top_level, mode, ...).
  • Ties between levels.
  • Whether a similar helper makes sense for Choice, where choice already is the top option.

Activity

  1. added
    enhancement
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions