Skip to content

Commit

Permalink
Add stub file for generic
Browse files Browse the repository at this point in the history
  • Loading branch information
lk-geimfari committed Jan 7, 2024
1 parent 854fd81 commit b8fb804
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 40 deletions.
63 changes: 23 additions & 40 deletions mimesis/providers/generic.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,35 @@
"""Provides all at one."""

import importlib
import inspect
import typing as t

from mimesis.locales import Locale
from mimesis.providers.address import Address
from mimesis.providers.base import BaseDataProvider, BaseProvider
from mimesis.providers.binaryfile import BinaryFile
from mimesis.providers.choice import Choice
from mimesis.providers.code import Code
from mimesis.providers.cryptographic import Cryptographic
from mimesis.providers.date import Datetime
from mimesis.providers.development import Development
from mimesis.providers.file import File
from mimesis.providers.finance import Finance
from mimesis.providers.food import Food
from mimesis.providers.hardware import Hardware
from mimesis.providers.internet import Internet
from mimesis.providers.numeric import Numeric
from mimesis.providers.path import Path
from mimesis.providers.payment import Payment
from mimesis.providers.person import Person
from mimesis.providers.science import Science
from mimesis.providers.text import Text
from mimesis.providers.transport import Transport
from mimesis.types import MissingSeed, Seed

__all__ = ["Generic"]

DEFAULT_PROVIDERS = (
Address,
BinaryFile,
Finance,
Choice,
Code,
Choice,
Datetime,
Development,
File,
Food,
Hardware,
Internet,
Numeric,
Path,
Payment,
Person,
Science,
Text,
Transport,
Cryptographic,
DEFAULT_PROVIDERS: tuple[str, ...] = (
"Address",
"BinaryFile",
"Finance",
"Choice",
"Code",
"Datetime",
"Development",
"File",
"Food",
"Hardware",
"Internet",
"Numeric",
"Path",
"Payment",
"Person",
"Science",
"Text",
"Transport",
"Cryptographic",
)


Expand All @@ -65,6 +46,8 @@ def __init__(
self.locale = locale

for provider in DEFAULT_PROVIDERS:
module = importlib.import_module("mimesis.providers")
provider = getattr(module, provider)
name = getattr(provider.Meta, "name") # type: ignore

# Check if a provider is locale-dependent.
Expand Down
44 changes: 44 additions & 0 deletions mimesis/providers/generic.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import typing as t

from mimesis import providers
from mimesis.locales import Locale
from mimesis.providers.base import BaseProvider
from mimesis.types import Seed

__all__ = ["Generic"]

class Generic(BaseProvider):
locale: Locale
# Locale-dependent providers
person: providers.Person
text: providers.Text
address: providers.Address
finance: providers.Finance
datetime: providers.Datetime
food: providers.Food

# Locale-independent providers
cryptography: providers.Cryptographic
binaryfile: providers.BinaryFile
file: providers.File
code: providers.Code
path: providers.Path
choice: providers.Choice
numeric: providers.Numeric
payment: providers.Payment
hardware: providers.Hardware
development: providers.Development
internet: providers.Internet
science: providers.Science
transport: providers.Transport

def __init__(self, locale: Locale = ..., seed: Seed = ...) -> None: ...

class Meta:
name: t.Final[str]
def __getattr__(self, attrname: str) -> t.Any: ...
def __dir__(self) -> list[str]: ...
def reseed(self, seed: Seed = ...) -> None: ...
def add_provider(self, cls: t.Type[BaseProvider], **kwargs: t.Any) -> None: ...
def add_providers(self, *providers: t.Type[BaseProvider]) -> None: ...
def __iadd__(self, other: t.Type[BaseProvider]) -> Generic: ...

0 comments on commit b8fb804

Please sign in to comment.