type issue
commit
09c967d1ac
|
@ -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()
|
Loading…
Reference in New Issue