-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ delete extra generic and improve the
Accessor
- Loading branch information
Showing
14 changed files
with
89 additions
and
43 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
from saleyo import Mixin, Insert, ReName | ||
from saleyo import Mixin, Insert | ||
from saleyo.operation.accessor import Accessor, FunctionAccessor | ||
|
||
|
||
class Foo: | ||
def hello(self): | ||
print("hello world") | ||
__value: int = 1 | ||
|
||
def __increase_value(self) -> None: | ||
self.__value += 1 | ||
|
||
def get_val(self): | ||
return self.__value | ||
|
||
|
||
@Mixin(target=Foo) | ||
class MixinFoo: | ||
goodbye = ReName("hello", "goodbye") | ||
value_accessor: Accessor[int] = Accessor("__value") | ||
increase_value: FunctionAccessor[[Foo], None] = FunctionAccessor("__increase_value") | ||
|
||
@Insert | ||
def helloworld(self): # type: ignore | ||
self.goodbye() | ||
def helloworld(self): | ||
assert isinstance(self, Foo) | ||
MixinFoo.value_accessor.value += 1 | ||
MixinFoo.increase_value(self) | ||
|
||
|
||
foo: MixinFoo = Foo() | ||
foo.helloworld() | ||
assert isinstance(foo, Foo) | ||
print(foo.get_val()) | ||
print(MixinFoo.value_accessor) |
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