Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dataprofiler/labelers/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __new__(
class BaseModel(metaclass=abc.ABCMeta):
"""For labeling data."""

_BaseModel__subclasses: dict[str, type[BaseModel]] = {}
__subclasses: dict[str, type[BaseModel]] = {}
__metaclass__ = abc.ABCMeta

# boolean if the label mapping requires the mapping for index 0 reserved
Expand Down Expand Up @@ -90,7 +90,7 @@ def __eq__(self, other: object) -> bool:
def _register_subclass(cls) -> None:
"""Register a subclass for the class factory."""
if not inspect.isabstract(cls):
cls._BaseModel__subclasses[cls.__name__.lower()] = cls
cls.__subclasses[cls.__name__.lower()] = cls

@property
def label_mapping(self) -> dict[str, int]:
Expand Down Expand Up @@ -156,7 +156,7 @@ def get_class(cls, class_name: str) -> type[BaseModel] | None:
from .column_name_model import ColumnNameModel # NOQA
from .regex_model import RegexModel # NOQA

return cls._BaseModel__subclasses.get(class_name.lower(), None)
return cls.__subclasses.get(class_name.lower(), None)

def get_parameters(self, param_list: list[str] | None = None) -> dict:
"""
Expand Down
12 changes: 5 additions & 7 deletions dataprofiler/labelers/data_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,14 @@ def __init__(self, **parameters: Any) -> None:
def _register_subclass(cls) -> None:
"""Register a subclass for the class factory."""
if not inspect.isabstract(cls):
cls._BaseDataProcessor__subclasses[ # type: ignore
cls.__name__.lower()
] = cls
cls.__subclasses[cls.__name__.lower()] = cls

@classmethod
def get_class(cls: type[Processor], class_name: str) -> type[Processor] | None:
def get_class(
cls: type[BaseDataProcessor], class_name: str
) -> type[BaseDataProcessor] | None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, makes sense that it isn't type[Processor]. While generics make sense at the top of the class, this output isn't related to the cls, but to the str.

"""Get class of BaseDataProcessor object."""
return cls._BaseDataProcessor__subclasses.get( # type: ignore
class_name.lower(), None
)
return cls.__subclasses.get(class_name.lower(), None)

def __eq__(self, other: object) -> bool:
"""
Expand Down