Skip to content

Commit

Permalink
fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
fcurella committed Apr 4, 2024
1 parent 9cfa524 commit f6cb199
Show file tree
Hide file tree
Showing 5 changed files with 789 additions and 404 deletions.
6 changes: 2 additions & 4 deletions faker/providers/person/pl_PL/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4115,8 +4115,7 @@ def identity_card_number(self) -> str:

return "".join(str(character) for character in identity)

@staticmethod
def pesel_compute_check_digit(pesel: str) -> int:
def pesel_compute_check_digit(self, pesel: str) -> int:
checksum_values = [9, 7, 3, 1, 9, 7, 3, 1, 9, 7]
return sum(int(a) * b for a, b in zip(pesel, checksum_values)) % 10

Expand Down Expand Up @@ -4168,8 +4167,7 @@ def pesel(self, date_of_birth: Optional[datetime] = None, sex: Optional[str] = N

return pesel

@staticmethod
def pwz_doctor_compute_check_digit(x: Sequence[int]) -> int:
def pwz_doctor_compute_check_digit(self, x: Sequence[int]) -> int:
return sum((i + 1) * d for i, d in enumerate(x)) % 11

def pwz_doctor(self) -> str:
Expand Down
6 changes: 4 additions & 2 deletions faker/providers/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def pystr_format(
) -> str:
return self.bothify(self.generator.parse(string_format), letters=letters)

@no_type_check
def pyfloat(
self,
left_digits: Optional[int] = None,
Expand All @@ -151,8 +152,9 @@ def pyfloat(
raise ValueError("A float number cannot have less than 0 digits in its " "fractional part")
if left_digits == 0 and right_digits == 0:
raise ValueError("A float number cannot have less than 0 digits in total")
if None not in (min_value, max_value) and min_value > max_value:
raise ValueError("Min value cannot be greater than max value")
if min_value is not None and max_value is not None:
if min_value > max_value:
raise ValueError("Min value cannot be greater than max value")
if None not in (min_value, max_value) and min_value == max_value:
raise ValueError("Min and max value cannot be the same")
if positive and min_value is not None and min_value <= 0:
Expand Down
15 changes: 5 additions & 10 deletions faker/providers/ssn/it_IT/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8094,13 +8094,11 @@ def _get_surname_letters(self) -> str:
surname_part = "".join(surname_consonants)[:3]
return surname_part

@staticmethod
def _transliterate_name(name: str) -> str:
def _transliterate_name(self, name: str) -> str:
nfkd_form: str = unicodedata.normalize("NFKD", name)
return "".join([c for c in nfkd_form if unicodedata.combining(c) == 0])

@staticmethod
def _get_vowels(sequence: str) -> list:
def _get_vowels(self, sequence: str) -> list:
"""
Returns list of vowels in provided string
"""
Expand All @@ -8110,8 +8108,7 @@ def _get_vowels(sequence: str) -> list:
vowels.append(char)
return vowels

@staticmethod
def _get_consonants(sequence: str) -> list:
def _get_consonants(self, sequence: str) -> list:
"""
Returns list of consonants in provided string
"""
Expand All @@ -8121,8 +8118,7 @@ def _get_consonants(sequence: str) -> list:
consonants.append(char)
return consonants

@staticmethod
def _pad_shorter(sequence: str) -> str:
def _pad_shorter(self, sequence: str) -> str:
"""
Pads shorter string with the allowed char
"""
Expand All @@ -8137,8 +8133,7 @@ def is_leap_year(year: int) -> bool:
return True
return False

@staticmethod
def _get_max_day(is_leap_year: bool, month: str) -> int:
def _get_max_day(self, is_leap_year: bool, month: str) -> int:
"""
Returns the maximum day for the current month
"""
Expand Down
2 changes: 1 addition & 1 deletion faker/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __getattr__(self, attr: str) -> Any:
factory = self._select_factory(attr)
return getattr(factory, attr)

def __deepcopy__(self, memodict: Dict = {}) -> "Faker":
def __deepcopy__(self, memodict):
cls = self.__class__
result = cls.__new__(cls)
result._locales = copy.deepcopy(self._locales)
Expand Down

0 comments on commit f6cb199

Please sign in to comment.