Last active
February 13, 2020 13:05
-
-
Save podhmo/66e1023a4c7a105add284f9f42cb0d88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from monogusa import component | |
class Foo: | |
pass | |
@component | |
def foo() -> Foo: | |
return Foo() | |
def use(foo: Foo) -> None: | |
print(foo) | |
if __name__ == "__main__": | |
from monogusa.cli import run | |
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from monogusa import component | |
class Foo: | |
pass | |
@component | |
def foo() -> Foo: | |
return Foo() | |
def use(f: Foo) -> None: | |
print(f) | |
if __name__ == "__main__": | |
from monogusa.cli import run | |
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from monogusa import default_component | |
class Foo: | |
pass | |
@default_component | |
def foo() -> Foo: | |
return Foo() | |
def use(f: Foo) -> None: | |
print(f) | |
if __name__ == "__main__": | |
from monogusa.cli import run | |
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from monogusa import component | |
from monogusa.dependencies import resolve_args | |
@component | |
def one() -> int: | |
return 1 | |
def use(one: int) -> None: | |
print(one) | |
print("!", resolve_args(use)) | |
# ! [1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing_extensions as tx | |
from monogusa import default_component | |
from monogusa.dependencies import resolve_args | |
@tx.runtime_checkable | |
class P(tx.Protocol): | |
def foo(self) -> str: | |
... | |
class I: | |
def foo(self) -> str: | |
return "I" | |
@default_component | |
def foo() -> P: | |
return I() | |
def use(p: P) -> None: | |
print(p.foo()) | |
use(*resolve_args(use)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
from monogusa import default_component | |
from monogusa.dependencies import resolve_args | |
class P(abc.ABC): | |
def foo(self) -> str: | |
... | |
class I(P): | |
def foo(self) -> str: | |
return "I" | |
@default_component | |
def foo() -> P: | |
return I() | |
def use(p: P) -> None: | |
print(p.foo()) | |
use(*resolve_args(use)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00: | |
python $(shell echo $@*.py) use | |
01: | |
python $(shell echo $@*.py) use | |
02: | |
python $(shell echo $@*.py) use | |
03: | |
python $(shell echo $@*.py) | |
04: | |
python $(shell echo $@*.py) | |
05: | |
python $(shell echo $@*.py) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment