Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Parameterized types of generic classes sometimes shared between class instances #590

@jakebailey

Description

@jakebailey

In the below, both intval and strval come to be int, even though hovering over boxedint and boxedstr show Box[int] and Box[str] respectively.

from typing import TypeVar, Generic

_T = TypeVar("_T")

class Box(Generic[_T]):
    def __init__(self, v: _T):
        self.v = v
    
    def get(self) -> _T:
        return self.v


boxedint = Box(1234)
intval = boxedint.get()

boxedstr = Box("foo")
strval = boxedstr.get()

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions