Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P760
Python 3.10 ADT
Active
Public
Actions
Authored by
vlorentz
on Sep 13 2020, 10:43 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
from
__future__
import
annotations
import
dataclasses
import
typing
import
rust_parser.gll.semantics
@typing.sealed
class
Main
(
metaclass
=
rust_parser
.
gll
.
semantics
.
ADT
):
_variants
=
(
"Foo"
,
"Bar"
,
"Baz"
)
@dataclasses.dataclass
class
Foo
:
foo1
:
str
foo2
:
str
@dataclasses.dataclass
class
Bar
:
bar
:
int
@dataclasses.dataclass
class
Baz
:
baz
:
Main
assert
issubclass
(
Main
.
Foo
,
Main
)
o
:
Main
=
Main
.
Foo
(
foo1
=
"a"
,
foo2
=
"b"
)
match
o
:
case
Main
.
Foo
(
foo1
,
foo2
):
print
(
foo1
,
foo2
)
case
Main
.
Bar
(
_
)
|
Main
.
Baz
(
_
):
pass
Event Timeline
vlorentz
created this paste.
Sep 13 2020, 10:43 AM
2020-09-13 10:43:32 (UTC+2)
vlorentz
edited the content of this paste.
(Show Details)
Sep 13 2020, 10:49 AM
2020-09-13 10:49:41 (UTC+2)
Log In to Comment