Skip to content

Commit

Permalink
Fix typing on pydecimal
Browse files Browse the repository at this point in the history
  • Loading branch information
fcurella committed Jun 20, 2024
1 parent d0bfbfb commit 10c2ba3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions faker/providers/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

from decimal import Decimal
from enum import Enum
from numbers import Number
from typing import Any, Dict, Iterable, Iterator, List, Optional, Set, Tuple, Type, TypeVar, Union, cast, no_type_check

from faker.typing import BasicNumber

from ...exceptions import BaseFakerException
from .. import BaseProvider, ElementsType

Expand Down Expand Up @@ -285,8 +286,8 @@ def pydecimal(
left_digits: Optional[int] = None,
right_digits: Optional[int] = None,
positive: bool = False,
min_value: Optional[Number] = None,
max_value: Optional[Number] = None,
min_value: Optional[BasicNumber] = None,
max_value: Optional[BasicNumber] = None,
) -> Decimal:
if left_digits is not None and left_digits < 0:
raise ValueError("A decimal number cannot have less than 0 digits in its " "integer part")
Expand Down
4 changes: 2 additions & 2 deletions faker/proxy.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2247,8 +2247,8 @@ class Faker:
left_digits: Optional[int] = ...,
right_digits: Optional[int] = ...,
positive: bool = ...,
min_value: Optional[float] = ...,
max_value: Optional[float] = ...,
min_value: Union[float, int, None] = ...,
max_value: Union[float, int, None] = ...,
) -> Decimal: ...
def pydict(
self,
Expand Down
1 change: 1 addition & 0 deletions faker/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(
self.security_code_length = security_code_length


BasicNumber = Union[float, int]
CardType = TypeVar("CardType", "CreditCard", str)
DateParseType = Union[date, datetime, timedelta, str, int]
HueType = Union[str, float, int, Sequence[int]]
Expand Down

0 comments on commit 10c2ba3

Please sign in to comment.