Clarification on how Typevars in a generic function should resolve
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 8
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- python
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100