This repository has been archived by the owner on Jun 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PAUSED branch 'feature/#151/represent-local-env' into dev
- Loading branch information
Showing
44 changed files
with
657 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .clear_args_kwargs import * | ||
from .export import * | ||
from .no_export import * |
12 changes: 12 additions & 0 deletions
12
conf/script/src/ext/meta_prog/encapsulation/clear_args_kwargs.py
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__all__ = ['ClearArgsKwargs'] | ||
|
||
from typing import Any | ||
|
||
|
||
class ClearArgsKwargs: | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
super().__init__() | ||
|
||
def __new__(cls, *args, **kwargs) -> Any: | ||
return super().__new__(cls) |
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,14 +1,19 @@ | ||
__all__ = ['TAlias_generic_cls', | ||
'GenericClassWrapperDataMixin'] | ||
|
||
from typing import Final, Generic | ||
from typing import Generic | ||
|
||
TAlias_generic_cls = type[Generic] | ||
|
||
|
||
class GenericClassWrapperDataMixin: | ||
wrapped_generic_cls: Final[TAlias_generic_cls] | ||
wrapped_generic_cls: TAlias_generic_cls | ||
|
||
def __init__(self, generic_cls: TAlias_generic_cls, *args, **kwargs) -> None: | ||
self.wrapped_generic_cls = generic_cls | ||
def __new__(cls, generic_cls: TAlias_generic_cls, *args, **kwargs): | ||
instance = super().__new__(cls, *args, **kwargs) | ||
instance.wrapped_generic_cls = generic_cls | ||
|
||
return instance | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
super().__init__(*args, **kwargs) |
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,16 +1,22 @@ | ||
__all__ = ['TAlias_Generics_By_TypeVars', | ||
'GenericsDataMixin'] | ||
|
||
from typing import Final, Optional, TypeVar | ||
from typing import Optional, TypeVar | ||
|
||
TAlias_Generics_By_TypeVars = dict[TypeVar, Optional[type]] | ||
|
||
|
||
class GenericsDataMixin: | ||
generics_by_type_vars: Final[TAlias_Generics_By_TypeVars] | ||
generics_by_type_vars: TAlias_Generics_By_TypeVars | ||
|
||
def __init__(self, *args, | ||
generics_by_type_vars: TAlias_Generics_By_TypeVars = None, | ||
**kwargs) -> None: | ||
self.generics_by_type_vars = generics_by_type_vars if generics_by_type_vars is not None else {} | ||
def __new__(cls, | ||
*args, | ||
generics_by_type_vars: TAlias_Generics_By_TypeVars = None, | ||
**kwargs): | ||
instance = super().__new__(cls, *args, **kwargs) | ||
instance.generics_by_type_vars = generics_by_type_vars if generics_by_type_vars is not None else {} | ||
|
||
return instance | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
super().__init__(*args, **kwargs) |
32 changes: 32 additions & 0 deletions
32
conf/script/src/ext/meta_prog/generics/proxy_verifier_mixin.py
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
__all__ = ['ProxyGenericsVerifierMixin'] | ||
|
||
from typing import TypeVar | ||
|
||
from .cls_wrapper_data import * | ||
from .data import * | ||
|
||
|
||
class ProxyGenericsVerifierMixin(GenericsDataMixin, GenericClassWrapperDataMixin): | ||
|
||
def __new__(cls, *args, **kwargs): | ||
instance: cls = super().__new__(cls, *args, **kwargs) | ||
instance._verify_generics() | ||
|
||
return instance | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
super().__init__(*args, **kwargs) | ||
|
||
def _verify_generics(self) -> None: | ||
generic_type_vars: tuple[TypeVar] = self.__get_cls_generic_type_vars(self.wrapped_generic_cls) | ||
|
||
if len(self.generics_by_type_vars) != len(generic_type_vars): | ||
raise TypeError(f'Wrong number of generic types for {type(self.wrapped_generic_cls)}.') | ||
|
||
# TODO : Change me for checking if it matches the actual TypeVars, i.e. if the bound and the constraints are respected. | ||
if tuple(self.generics_by_type_vars.keys()) != generic_type_vars: | ||
raise TypeError(f'Supplied generic types do not match the class\'s generic type vars requirements.') | ||
|
||
@staticmethod | ||
def __get_cls_generic_type_vars(cls: TAlias_generic_cls) -> tuple[TypeVar]: | ||
return cls.__parameters__ |
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 +1,2 @@ | ||
from .path import * | ||
from .string import * |
Oops, something went wrong.