lk-geimfari / mimesis

Mimesis is a robust data generator for Python that can produce a wide range of fake data in multiple languages.
https://mimesis.name
MIT License
4.44k stars 336 forks source link

Moving utils.pull to BaseDataProvider #568

Closed lk-geimfari closed 5 years ago

lk-geimfari commented 5 years ago

Feature request

Thesis

I suggest moving utils.pull to BaseDataProvider because it's only needed for locale-dependent providers, which are all subclasses of BaseDataProvider.

Reasoning

We are forced to always manually import pull to the modules where are we create new providers and repeat the same code, although the pull is needed only for locale-dependent providers which are all inherited from BaseDataProvider. It will be much logically correct to keep pull in provider BaseDataProvider I think.

The idea is simple, instead of this:

from mimesis.utils import pull

class OldProvider(BaseDataProvider):

    def __init__(self, *args, **kwargs):
        """Initialize attributes.
        """
        super().__init__(*args, **kwargs)
        self._datafile = 'datetime.json'
        self._data = pull(self._datafile, self.locale)

Use this:

class NewProvider(BaseDataProvider):

    def __init__(self, *args, **kwargs):
        """Initialize attributes.
        """
        super().__init__(*args, **kwargs)
        self._datafile = 'datetime.json'
        self.pull(self._datafile)

After this we'll able to use pull withot any extra importing.

That's just discussion, I have not started working on this yet.

sobolevn commented 5 years ago

@lk-geimfari I agree. I think that all modules that start with util are just not placed well in some other entities. Related: https://wemake-python-styleguide.readthedocs.io/en/latest/pages/violations/naming.html#wemake_python_styleguide.violations.naming.WrongModuleNameViolation

So, maybe we can refactor the whole module?

lk-geimfari commented 5 years ago

@sobolevn Yeah, I think about it too. This release will contain breaking things anyway (because there was too much really old and bad solution inherited from the very early version of the church). Any possible breaking features must be implemented here, in v3.0.0.

Can you, please, create an issue?

lk-geimfari commented 5 years ago

I also suggest renaming other internal modules with bad names, such as helpers, __version__

lk-geimfari commented 5 years ago

Done.