Exemplo n.º 1
0
        class F(metaclass=Classtools, slots=True):
            none = 'conventional class variable'
            a: Any = ...
            b: attr = 0 | lazy('get_b')
            c: attr = 1 | lazy('get_c')
            d: ClassVar[str] = Attr('d', lazy=False)
            e: int = 1 | lazy('get_e') | skip
            with OPTIONS | lazy('get_section'):
                f: attr = 8
                g: bool = True / lazy
            h: Any = Attr('replace', lazy='get_h')
            k: attr = ... | lazy('get_k') | const
            m: attr = () | lazy('get_m') | const | skip
            n: ClassVar[tuple] = () / lazy('dont_care')

            def get_b(self):
                raise GetterError

            def get_c(self):
                return 'c_value'

            def get_section(self):
                return 'section_value'

            def get_e(self):
                raise GetterError

            def get_h(self):
                return 'h_value'

            def get_k(self):
                return 'k_value'

            def get_m(self):
                return ('m_value', ) * 3
Exemplo n.º 2
0
 class E(metaclass=Classtools, slots=True):
     none = 'conventional class variable'
     a: Any = ...
     b: bool = ... | const | skip
     c: attr
     d: ClassVar[str] = Attr('d', tag=None)
     e: int = 1 | const
     with OPTIONS | const:
         f: attr = 8
         g: bool = True / const
     h: Any = Attr('replace', const=True)
Exemplo n.º 3
0
        class H(metaclass=Classtools, slots=True):
            none = 'conventional class variable'
            a: Any = ...
            b: attr = ... | kw
            e: ClassVar[str] = Attr('e_classvar', kw=False)
            f: int = 1 / kw | skip
            with OPTIONS(kw=True):
                g: attr = 8
                h: bool = True / kw
            k: Any = Attr('replace', tag='tag_h')
            m: attr = () | tag('tag_m') | lazy('get_m') | const | skip
            n: ClassVar[Union[str, int]] = 'n_classvar'

            def get_m(self):
                return 'm_value'
Exemplo n.º 4
0
        class G(metaclass=Classtools, slots=True):
            none = 'conventional class variable'
            a: Any = ...
            b: attr = ... | tag(object) | skip
            k: attr = ... | tag('tag_k') | const
            c: attr = 1 | tag('tag_c')
            d: ClassVar[str] = Attr('b', tag=None)
            e: int = 1 | tag('tag_e') | skip
            with TAG('tag_section'):
                f: attr = 8
                g: bool = True / tag
            h: Any = Attr('replace', tag='tag_h')
            m: attr = () | tag('tag_m') | lazy('get_m') | const | skip
            n: ClassVar[tuple] = () / tag('dont_care')

            def get_m(self):
                return 'm_value'
Exemplo n.º 5
0
 class D(metaclass=Classtools, slots=True):
     none = 'conventional class variable'
     k: attr = ... | skip
     b: attr
     d: int = 1 | skip
     e: attr = 8 / skip
     f: Any = 'f'
     g: attr = Attr('replace', skip=None)
Exemplo n.º 6
0
 class C(metaclass=Classtools, slots=True):
     with OPTIONS(tag='test'):
         e: int
     with TAG('test'):
         d: attr = None
     with OPTIONS | tag('test'):
         c: tuple = (1, 2, 3)
     no_tag: attr = 1
     with OPTIONS:
         b: int = -8 | tag('test')
     a: int = Attr(-8, tag='test')
Exemplo n.º 7
0
        class K(metaclass=Classtools, slots=True):
            none = 'conventional class variable'
            a: Any = ...
            b: attr = ... | skip
            p: attr = ... | const
            j: attr = ... | lazy('get_j')
            c: attr = [1, 2, 3]
            d: ClassVar[str] = Attr({1: 'a'})
            e: int = 'will be replaced with []'
            f: attr = ClassCopy()
            g: attr = ClassNoCopy()
            h: Any = Attr('replace', tag='tag_h')
            m: attr = {} | tag('max options') | lazy('get_m') | const | kw
            n: ClassVar[list] = []

            def get_m(self):
                return ['m_value']

            def get_j(self):
                return ['j_value']
Exemplo n.º 8
0
        class M(metaclass=Classtools, slots=True, init=False):

            none = 'conventional class variable'
            a: Any = ...
            b: attr = ... | skip
            p: attr = ... | const
            j: attr = ... | lazy('get_j')
            c: attr = [1, 2, 3]
            d: ClassVar[str] = {1: 'a'}
            e: str = 'e'
            f: attr = Attr() | kw
            g: attr = 'g' | kw
            h: Any = Attr(42, tag='tag_h')
            m: attr = {} | tag('max options') | lazy('get_m') | const | kw
            n: ClassVar[list] = []

            def get_m(self):
                return 'm_value'

            def get_j(self):
                return 'j_value'
Exemplo n.º 9
0
 class D_ERROR_CLASSVAR_SKIP(metaclass=Classtools, slots=True):
     a: ClassVar[str] = Attr('a', skip=1)