Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(phone) Upgrade UA phone provider #2016

Merged
merged 8 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 63 additions & 1 deletion faker/providers/phone_number/uk_UA/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from .. import ElementsType
from .. import Provider as PhoneNumberProvider


class Provider(PhoneNumberProvider):
formats = (
formats: ElementsType[str] = (
"###-##-##",
"### ## ##",
"0## ### ## ##",
Expand All @@ -12,3 +13,64 @@ class Provider(PhoneNumberProvider):
"+380 (##) ###-##-##",
"+380 ## ### ## ##",
)

# info: https://ru.wikipedia.org/wiki/MSISDN
msisdn_formats: ElementsType[str] = ("############",)

# info: https://en.wikipedia.org/wiki/Telephone_numbers_in_Ukraine
country_calling_codes: ElementsType[str] = (
"+38031",
"+38032",
"+38033",
"+38034",
"+38035",
"+38036",
"+38037",
"+38038",

"+38041",
"+38043",
"+38044",
"+38045",
"+38046",
"+38047",
"+38048",
"+38049",

"+38050",
"+38051",
"+38052",
"+38053",
"+38054",
"+38055",
"+38056",
"+38057",

"+38061",
"+38062",
"+38063",
"+38063",
"+38065",
"+38066",
"+38067",
"+38068",
"+38069",

"+38070",
"+38071",
"+38072",
"+38073",

"+3800",

"+38090",
"+38091",
"+38092",
"+38093",
"+38094",
"+38095",
"+38096",
"+38097",
"+38098",
"+38099",
)
10 changes: 6 additions & 4 deletions faker/proxy.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

Check failure on line 1 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.
from typing import Any, Iterable, Sequence, Union, Type, Dict, List, Iterator, Tuple, Optional, TypeVar, Set
from enum import Enum
from faker.providers import T
import datetime

from decimal import Decimal
from faker.providers.python import TEnum
from enum import Enum
from typing import Any, Dict, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union

from faker.generator import Generator
from faker.providers import T
from faker.providers.python import TEnum

Check failure on line 10 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

Cannot redefine "T" as a type variable

Check failure on line 10 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

Invalid assignment target

Check failure on line 10 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

Cannot redefine "T" as a type variable

Check failure on line 10 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

Invalid assignment target

Check failure on line 10 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

Cannot redefine "T" as a type variable

Check failure on line 10 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

Invalid assignment target

Check failure on line 10 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

Cannot redefine "T" as a type variable

Check failure on line 10 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

Invalid assignment target

Check failure on line 11 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

Cannot redefine "TEnum" as a type variable

Check failure on line 11 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

Invalid assignment target

Check failure on line 11 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

Cannot redefine "TEnum" as a type variable

Check failure on line 11 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

Invalid assignment target

Check failure on line 11 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

Cannot redefine "TEnum" as a type variable

Check failure on line 11 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

Invalid assignment target

Check failure on line 11 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

Cannot redefine "TEnum" as a type variable

Check failure on line 11 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

Invalid assignment target
T = TypeVar("T")
TEnum = TypeVar("TEnum", bound=Enum)

Expand Down Expand Up @@ -142,7 +144,7 @@
:returns: A random postcode within the provided state abbreviation

:param state_abbr: A state abbreviation
"""

Check failure on line 147 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

Name "collections" is not defined

Check failure on line 147 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

Name "Collection" is not defined

Check failure on line 147 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

Name "collections" is not defined

Check failure on line 147 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

Name "Collection" is not defined

Check failure on line 147 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

Name "collections" is not defined

Check failure on line 147 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

Name "Collection" is not defined

Check failure on line 147 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

Name "collections" is not defined

Check failure on line 147 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

Name "Collection" is not defined
...
def random_choices(self, elements: Union[Collection[str], Collection[T], collections.OrderedDict[T, float]] = ..., length: Optional[int] = ...) -> Sequence[T]:
"""
Expand Down Expand Up @@ -197,7 +199,7 @@

This method will return an empty string 50% of the time,
and each digit has a 1/20 chance of being generated.
"""

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

Name "collections" is not defined

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

Name "Collection" is not defined

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

A function returning TypeVar should receive at

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

Name "collections" is not defined

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

Name "Collection" is not defined

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

A function returning TypeVar should receive at

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

Name "collections" is not defined

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

Name "Collection" is not defined

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

A function returning TypeVar should receive at

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

Name "collections" is not defined

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

Name "Collection" is not defined

Check failure on line 202 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

A function returning TypeVar should receive at
...
def random_element(self, elements: Union[Collection[str], Collection[T], collections.OrderedDict[T, float]] = ...) -> T:
"""
Expand All @@ -215,7 +217,7 @@
("c", 0.15),
("d", 0.05),
])
"""

Check failure on line 220 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.8)

Name "collections" is not defined

Check failure on line 220 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.9)

Name "collections" is not defined

Check failure on line 220 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.10)

Name "collections" is not defined

Check failure on line 220 in faker/proxy.pyi

View workflow job for this annotation

GitHub Actions / typing (3.12)

Name "collections" is not defined
...
def random_elements(self, elements: Union[Collection[str], Collection[T], collections.OrderedDict[T, float]] = ..., length: Optional[int] = ..., unique: bool = ..., use_weighting: Optional[bool] = ...) -> Sequence[T]:
"""
Expand Down
8 changes: 5 additions & 3 deletions generate_stubs.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from collections import defaultdict
import inspect

Check failure on line 1 in generate_stubs.py

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.
import pathlib
import re

from collections import defaultdict
from typing import Any, Dict, List, Optional, Set, Tuple
from faker.config import AVAILABLE_LOCALES, PROVIDERS
from faker import Factory, Faker

import faker.proxy

from faker import Factory, Faker
from faker.config import AVAILABLE_LOCALES, PROVIDERS

BUILTIN_MODULES_TO_IGNORE = ["builtins"]
GENERIC_MANGLE_TYPES_TO_IGNORE = ["builtin_function_or_method", "mappingproxy"]
MODULES_TO_FULLY_QUALIFY = ["datetime"]
Expand Down