Skip to content

Commit

Permalink
add info logging about structuring unknown class
Browse files Browse the repository at this point in the history
  • Loading branch information
Pocoder committed Feb 1, 2023
1 parent 732c4ee commit 0615b90
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/client/primitives/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
]

import inspect
import logging
import typing
from copy import copy
from enum import Enum
Expand All @@ -27,6 +28,8 @@

E = TypeVar('E', bound=Enum)

logger = logging.getLogger(__file__)


class VariantRegistry:

Expand All @@ -53,11 +56,13 @@ def register(self, type_: type, value: E) -> type:

def generate_subtype(self, type_: type, value: E) -> type:
if not self.extendable:
raise NotImplementedError()
raise NotImplementedError("Only extendable VariantRegistry can generate subtype")

generated_type_name = '_Generated' + value.value.title() + type_.__name__
BaseTolokaObjectMetaclass(generated_type_name, (type_,), {}, spec_value=value)

logger.error(f'{generated_type_name} class was generated. Probably it is a new functionality on the platform.\n'
'If you want it to be supported by toloka-kit faster '
'you can make feature request here: https://github.com/Toloka/toloka-kit/issues/new/choose.')
return self.registered_classes[value]

def __getitem__(self, value: E) -> type:
Expand Down

0 comments on commit 0615b90

Please sign in to comment.