python / python/mypy

Mypy degrades inferred generic return type from tuple[type[T], ...] to object

Open
#20,891 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-inference topic-join-v-union
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report
Mypy incorrectly treats generic return type inferred from tuple[type[T], ...] as object

To Reproduce

Gist URL
Playground URL

Expected Behavior

Variable is recognized as int | str

Actual Behavior

Mypy error:

Argument 1 to "func_b" has incompatible type "object"; expected "int | str" Mypy(arg-type)

Your Environment

  • Mypy version used: 1.19.1
  • Python version used: 3.14.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Mypy playground or gist and reproduce the error using Mypy 1.19.1 and Python 3.14. Trace the generic return-type inference for tuple[type[T], ...] and verify that the value is recognized as int | str rather than object, with no incompatible-argument error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.