Skip to content
This repository has been archived by the owner on Jun 14, 2021. It is now read-only.

Test meta_prog/encapsulation Package #180

Open
benoit-dubreuil opened this issue Apr 26, 2021 · 0 comments
Open

Test meta_prog/encapsulation Package #180

benoit-dubreuil opened this issue Apr 26, 2021 · 0 comments
Assignees
Labels
Maintenance Refactor, etc

Comments

@benoit-dubreuil
Copy link
Owner

benoit-dubreuil commented Apr 26, 2021

Specifications

  • Test the meta_prog/encapsulation package, which is located inside the ext package.

Tips

Use the following scratch code as a starting point.

from typing import Generic, TypeVar

from ext.meta_prog.generics.cls_proxy_injector import GenericClassProxyInjectorMixin

T_A = TypeVar('T_A')
T_B = TypeVar('T_B')
T_Cls = TypeVar('T_Cls', bound='TestGeneric')
T_Cls2 = TypeVar('T_Cls2', bound='TestGeneric2')
T_Cls3 = TypeVar('T_Cls3', bound='TestGeneric3')


class TestGeneric(GenericClassProxyInjectorMixin, Generic[T_A, T_B]):

    def __init__(self: T_Cls, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        print(self.has_generics())
        print(self.generics_by_type_vars)

        print()


class TestGeneric2(GenericClassProxyInjectorMixin, list[str]):

    def __init__(self: T_Cls2, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        print(self.has_generics())
        print(self.generics_by_type_vars)

        print()


class TestGeneric3(GenericClassProxyInjectorMixin, Generic[T_A], list[T_A]):

    def __init__(self: T_Cls3, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        print(self.has_generics())
        print(self.generics_by_type_vars)

        print()


tmp = TestGeneric[str, int]
tmp.__class__
test_obj = tmp()
test_obj = TestGeneric()

test_obj2 = TestGeneric2()
TestGeneric2.__class_getitem__(item=None).__class__

test_obj3 = TestGeneric3[str]()
test_obj3 = TestGeneric3()
@benoit-dubreuil benoit-dubreuil added the Maintenance Refactor, etc label Apr 26, 2021
@benoit-dubreuil benoit-dubreuil self-assigned this Apr 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Maintenance Refactor, etc
Projects
None yet
Development

No branches or pull requests

1 participant