GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Literal[...] deduplication silently skips when values are unhashable · Issue #153896 · python/cpython

Literal[...] deduplication silently skips when values are unhashable #153896

New issue
Copy link
New issue
Copy link
Closed
Closed
Literal[...] deduplication silently skips when values are unhashable#153896
Copy link
Labels
sprintstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@Maxinho96
Maxinho96
opened on Jul 18, 2026
Issue body actions

Bug report

Bug description:

https://gist.github.com/devdanzin/3198710e3c0128fda5e0a7b4e0768e5f#5-literal-deduplication-silently-skips-when-values-are-unhashable

Findings

The issue text is wrong: the unhashable_fallback param is not used in Annotated or anywhere else.
The parameter was added and actively used in commit a7549b0 (gh-112281 / PR #112283, Mar 2024).
In that revision, Union dedup went through _remove_dups_flatten, which called _deduplicate with unhashable_fallback=True to handle unhashable metadata.

Why it is not used now:
In commit dc6d66f (gh-105499 / PR #105511, Mar 2025), typing.Union was merged with types.UnionType.
That rewrite removed the old Python-side Union construction path in typing.py (including _remove_dups_flatten and the old Union special-form machinery), so the only known caller of unhashable_fallback=True disappeared.
Today, _deduplicate still has the keyword parameter, but the remaining in-file call path (Literal handling) does not pass it.

I tried to just pass the argument, but then this existing test fails, which has this comment:

# Mutable arguments will not be deduplicated

The test was added with commit f03d318, when deduplication of Literals was first introduced. From the commit, it looks like excluding unhashable params from deduplication was the intended behavior.

Proposal

I propose to use the unhashable_fallback param anyway, and change the failing test, since the intended behavior doesn't seem right to me as of today: I think Literal should always deduplicate, even when the params are unhashable.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

  • gh-153896: Deduplicate mutable args in Literal type #153913
  • gh-153896: Deduplicate unhashable Literal params #153914
  • [3.15] gh-153896: Deduplicate unhashable arguments in typing.Literal (GH-153914) #153955
  • [3.14] gh-153896: Deduplicate unhashable arguments in typing.Literal (GH-153914) #153956
  • [3.13] gh-153896: Deduplicate unhashable arguments in typing.Literal (GH-153914) #153957

Activity

  1. Maxinho96
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jul 18, 2026
  2. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    topic-typing
    on Jul 18, 2026
  3. picnixz commented on Jul 18, 2026

    @picnixz
    picnixz
    on Jul 18, 2026 · Hidden as resolved
    show commentMore actions
  4. picnixz
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Jul 18, 2026
  5. johnslavik
    added
    sprint
    on Jul 18, 2026
  6. github-project-automation
    added this to Sprinton Jul 18, 2026
  7. github-project-automation
    moved this to Todo in Sprinton Jul 18, 2026
  8. picnixz
    removed
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Jul 18, 2026
  9. ZeroIntensity
    added a commit that references this issue on Jul 18, 2026

    gh-153896: Deduplicate unhashable arguments in `typing.Literal` (GH-1…

    a53b5b1
  10. tomasr8
    added 3 commits that reference this issue on Jul 19, 2026

    [3.14] gh-153896: Deduplicate unhashable arguments in `typing.Literal` (

    3156e83

    [3.13] gh-153896: Deduplicate unhashable arguments in `typing.Literal` (

    6fd942a

    [3.15] gh-153896: Deduplicate unhashable arguments in `typing.Literal` (

    61aa141
  11. tomasr8
    closed this as completedon Jul 19, 2026
  12. github-project-automation
    moved this from Todo to Done in Sprinton Jul 19, 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

    sprintstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • Sprint
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.