Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Clarification on how Typevars in a generic function should resolve

Open
#2,142 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Quiet
Tech stack
python

Research direction

Read the linked ty issue #2255 and its cited comments first, then compare their interpretations with the generic-function example here. Document the agreed rule for resolving T in func(B(), C()), including whether the call should be rejected; done means the typing community has a clear, recorded answer.

Written by the indexing model from the issue text.

Description

topic: documentation

Hi, regarding the issue opened here:

https://github.com/astral-sh/ty/issues/2255

Can you please provide clarification on how TypeVars in a function like func in the below code should be resolved?

class A:
    pass

class B(A):
    pass

class C(A):
    pass

def func[T: A](x: T, y: T) -> T:
    ...

func(B(), C()) # I think this should raise a type error by type checkers but no type checker (mypy, pyright, etc) raise an error for this

Please look at these comments:
https://github.com/astral-sh/ty/issues/2255#issuecomment-3697606854
https://github.com/astral-sh/ty/issues/2255#issuecomment-3697628015
https://github.com/astral-sh/ty/issues/2255#issuecomment-3698867080
https://github.com/astral-sh/ty/issues/2255#issuecomment-3699067335

Dominant language
Python
Stars
1.8k
Forks
302
Avg merge
23h
Merged PRs (30d)
8

Contributor guide

No contributing guide indexed for this repository

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.

More from python/typing

All issues in python/typing

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.