Skip to content

Instantly share code, notes, and snippets.

@YiLi225
Created November 15, 2022 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YiLi225/8ba5468cec0c6f75c4e6587a3ea4cf41 to your computer and use it in GitHub Desktop.
Save YiLi225/8ba5468cec0c6f75c4e6587a3ea4cf41 to your computer and use it in GitHub Desktop.
from typing import Any, Type, TypeVar
from dataclasses import dataclass
curType = TypeVar('curType', bound='Rectangle')
class Rectangle:
def __init__(self, length: float) -> None:
self.length = length
@classmethod
def from_width(cls: curType, width) -> curType:
return cls(length=width*2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment