From 09c967d1ac1eed5975677131b21a2c6df3ac8800 Mon Sep 17 00:00:00 2001 From: cymen Date: Tue, 5 Dec 2023 19:49:09 +0100 Subject: [PATCH] type issue --- something.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 something.py diff --git a/something.py b/something.py new file mode 100644 index 0000000..d67432f --- /dev/null +++ b/something.py @@ -0,0 +1,19 @@ +from typing import Self + +class Foo: + def __init__(self, x: int) -> None: + self.x = x + + def combine(self: Self, other: Self) -> Self: + return Foo(self.x + other.x) + + def __repr__(self: Self): + return f"Self {{ x: {self.x} }}" + +def main(): + f = Foo(3) + g = Foo(4) + h = f.combine(g) + print(f"{f=} {g=} {h=}") + +main() \ No newline at end of file