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 — Remove obsolete Literal deduplication assertion by AlexWaygood · Pull Request #785 · python/typing_extensions

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Aug 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fixes #784.

Summary

Remove the assertion that Literal[[], []].__args__ is ([], []). python/cpython#153914 deliberately changed typing.Literal to deduplicate unhashable arguments, so Python 3.14.7 now returns ([],) instead. On supported Python versions where typing_extensions.Literal aliases typing.Literal, the old assertion therefore contradicts the standard library behavior.

This PR just deletes the assertion entirely: the behaviour here is now version-dependent, and the assertion was always testing an implementation detail that wasn't really that important.

Historical context

  • The assertion entered typing_extensions in Fix various things with Literal #145. That PR addressed (🐞) Literal doesn't flatten it's arguments #113 and backported bpo-42345: Fix three issues with typing.Literal parameters cpython#23294 and bpo-42345: Fix hash implementation of typing.Literal cpython#23383. The assertion was copied verbatim with the rest of CPython's LiteralTests.test_args in the first commit of that PR. There was no discussion about this particular assertion on Fix various things with Literal #145.
  • The original CPython behavior was intentional. In the original review discussion, a reviewer proposed deduplicating unhashable arguments as well. The PR author noted that changing the shared deduplication helper would slow down Union, and Guido asked whether mutable Literal arguments were actually valid.
  • PEP 586 rejects mutable Literal arguments at type-checking time but intentionally does not validate them at runtime. The CPython reviewers therefore agreed not to deduplicate mutable arguments. Guido subsequently requested explicit __args__ coverage, and commit f653d680 introduced the exact assertion that Fix various things with Literal #145 later copied.
  • gh-153896: Deduplicate unhashable Literal params cpython#153914 revisited that historical decision and now deduplicates unhashable arguments too; the change was backported to Python 3.13, 3.14, and 3.15. The old assertion is consequently obsolete and does not represent a typing_extensions implementation bug.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AlexWaygood
Remove obsolete Literal deduplication assertion
6e18c1c
@codecov

codecov Bot commented Aug 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.26%. Comparing base (83400e9) to head (6e18c1c).

@@            Coverage Diff             @@
##             main     #785      +/-   ##
==========================================
- Coverage   97.26%   97.26%   -0.01%     
==========================================
  Files           3        3              
  Lines        7860     7859       -1     
==========================================
- Hits         7645     7644       -1     
  Misses        215      215              
Flag Coverage Δ
3.10 88.85% <ø> (-0.01%) ⬇️
3.10.4 88.85% <ø> (-0.01%) ⬇️
3.11 88.02% <ø> (-0.01%) ⬇️
3.11.0 87.27% <ø> (-0.01%) ⬇️
3.12 87.96% <ø> (-0.01%) ⬇️
3.12.0 87.94% <ø> (-0.01%) ⬇️
3.13 83.39% <ø> (-0.01%) ⬇️
3.13.0 84.09% <ø> (-0.01%) ⬇️
3.14 79.53% <ø> (-0.01%) ⬇️
3.9 89.53% <ø> (-0.01%) ⬇️
3.9.12 89.53% <ø> (-0.01%) ⬇️
pypy3.10 88.68% <ø> (-0.01%) ⬇️
pypy3.11 87.88% <ø> (-0.01%) ⬇️
pypy3.9 89.37% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/test_typing_extensions.py 98.23% <ø> (-0.01%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood
AlexWaygood marked this pull request as ready for review August 12, 2026 11:56
srittau
srittau approved these changes Aug 12, 2026
View reviewed changes

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@AlexWaygood
AlexWaygood merged commit 79c903c into main Aug 12, 2026
25 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood
AlexWaygood deleted the alex/fix-literal-unhashable-args-test branch August 12, 2026 12:13
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Aug 18, 2026
dgarcia @bmwiedemann
Update python-typing_extensions to version 4.16.0 / rev 33 via SR 137…
93d7cc2
…0852

https://build.opensuse.org/request/show/1370852
by user dgarcia + anag_factory
- Drop not needed patch py314-fix-tests.patch
- Add upstream patch
  remove-obsolete-literal-deduplication-assertion.patch
  (gh#python/typing_extensions#785, bsc#1274786)
- Update to 4.16.0:
  * Avoid a DeprecationWarning when deprecated is applied to a
    coroutine function on Python 3.14.0.
  * Make `typing_extensions.TypeAliasType`'s `__module__` attribute
    writable.  Backport of CPython PR [#149172](python/cpython#149172).
  * Fix setting of `__required_keys__` and `__optional_keys__` when
    inheriting keys with the same name.
  * Add support for `AsyncIterator`, `io.Reader`, `io.Writer` and
    `os.PathLike` protocols as bases for other protocols.
  * Fix incorrect behaviour on Python 3.9 and Python 3.10 that meant
    that calling `isinstance` with
    `
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@srittau srittau srittau approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

test_typing_extensions.LiteralTests.test_args is failing with python 3.14.7

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@AlexWaygood @srittau
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.