[Feature] Get the type of generic typeVar in class
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
Having a class inheriting from a Generic make it possible to get type of the typeVar, possibly with a method like get_type or alike.
class MyClass(Generic[T]):
def __init__(self):
self.generic_type = T.get_type()
Pitch
Other languages' type system have this capability.
e.g.
C#;
Type type = abc.GetType().GetGenericArguments()[0];
https://stackoverflow.com/questions/557340/how-to-get-the-type-of-t-from-a-member-of-a-generic-class-or-method
C++;
template <class T>
class MyClass : public Base<T>
{
public:
T t;
decltype(t) t2;
};
Contributor guide
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
No files, tests, or entry points are identified in the issue, so begin by locating mypy's handling of Generic classes and type variables. Done would require an agreed design and implementation that lets a generic class obtain its type variable's type, with tests demonstrating the requested behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100