Skip to content

Commit

Permalink
refactor: replace GenderType with SexLiteral
Browse files Browse the repository at this point in the history
  • Loading branch information
fcurella committed Oct 11, 2022
1 parent 490a744 commit 2e055e3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions faker/providers/profile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from decimal import Decimal
from typing import Dict, List, Optional, Tuple, Union

from ...typing import GenderType
from ...typing import SexLiteral
from .. import BaseProvider


Expand All @@ -14,7 +14,7 @@ class Provider(BaseProvider):
"""

def simple_profile(self, sex: Optional[GenderType] = None) -> Dict[str, Union[str, date, GenderType]]:
def simple_profile(self, sex: Optional[SexLiteral] = None) -> Dict[str, Union[str, date, SexLiteral]]:
"""
Generates a basic profile with personal informations
"""
Expand All @@ -33,7 +33,7 @@ def simple_profile(self, sex: Optional[GenderType] = None) -> Dict[str, Union[st
}

def profile(
self, fields: Optional[List[str]] = None, sex: Optional[GenderType] = None
self, fields: Optional[List[str]] = None, sex: Optional[SexLiteral] = None
) -> Dict[str, Union[str, Tuple[Decimal, Decimal], List[str], date]]:
"""
Generates a complete profile.
Expand Down
4 changes: 2 additions & 2 deletions faker/providers/ssn/hu_HU/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from math import fmod
from typing import Optional

from ....typing import GenderType
from ....typing import SexLiteral
from .. import Provider as SsnProvider


Expand All @@ -11,7 +11,7 @@ def zfix(d: int) -> str:


class Provider(SsnProvider):
def ssn(self, dob: Optional[str] = None, gender: Optional[GenderType] = None) -> str:
def ssn(self, dob: Optional[str] = None, gender: Optional[SexLiteral] = None) -> str:
"""
Generates Hungarian SSN equivalent (személyazonosító szám or, colloquially, személyi szám)
Expand Down
4 changes: 2 additions & 2 deletions faker/providers/ssn/no_NO/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from typing import List, Optional, Sequence

from ....typing import GenderType
from ....typing import SexLiteral
from .. import Provider as SsnProvider


Expand All @@ -30,7 +30,7 @@ class Provider(SsnProvider):
scale1 = (3, 7, 6, 1, 8, 9, 4, 5, 2)
scale2 = (5, 4, 3, 2, 7, 6, 5, 4, 3, 2)

def ssn(self, dob: Optional[str] = None, gender: Optional[GenderType] = None) -> str:
def ssn(self, dob: Optional[str] = None, gender: Optional[SexLiteral] = None) -> str:
"""
Returns 11 character Norwegian personal identity code (Fødselsnummer).
Expand Down
4 changes: 2 additions & 2 deletions faker/providers/ssn/zh_CN/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import List, Optional

from ....typing import GenderType
from ....typing import SexLiteral
from .. import Provider as SsnProvider


Expand Down Expand Up @@ -3524,7 +3524,7 @@ class Provider(SsnProvider):
"820000",
]

def ssn(self, min_age: int = 18, max_age: int = 90, gender: Optional[GenderType] = None) -> str:
def ssn(self, min_age: int = 18, max_age: int = 90, gender: Optional[SexLiteral] = None) -> str:
"""
Return 18 character chinese personal identity code
Expand Down
2 changes: 1 addition & 1 deletion faker/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

DateParseType = Union[date, datetime, timedelta, str, int]
HueType = TypeVar("HueType", str, float, Sequence[int])
GenderType = TypeVar("GenderType", bound=Literal["M", "F"])
SexLiteral = Literal["M", "F"]
SeedType = Union[int, float, str, bytes, bytearray, None]

0 comments on commit 2e055e3

Please sign in to comment.