lk-geimfari / mimesis

Mimesis is a robust data generator for Python that can produce a wide range of fake data in multiple languages.

Home Page:https://mimesis.name

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add `from_typed_dict` schema

sobolevn opened this issue · comments

Let's say I have this typed dict:

class User(TypedDict):
    email: str
    password: str

I would love to just pass this metadata to mimesis to get my random data without any code duplication. Example of API that I am thinking of:

mf = Field(locale=Locale.RU)
schema = Schema(iterations=1, typed_dict_provider=User, schema=lambda: {
    # Customization is still fine:
    'email': mf(
        'person.email',
        domains=settings.TRUSTED_DOMAINS,
    ),
})

So, this will:

  • Generate password as a text, with no modifications
  • Generate email with a given modification

This feature seems to be very useful. It would be great to have such a feature in Mimesis.

I think I may try to work on it this weekend.

I think the difficulty here can only be with nested entities.

God, time has flown by so fast. I'm very busy at work and so I've never got round to doing it, but I really want to. I hope that at least this weekend I will be able to get it off the ground.