Skip to content

Commit

Permalink
Fix pydecimal handling of positive keyword (#2080)
Browse files Browse the repository at this point in the history
  • Loading branch information
tahzeer authored Aug 23, 2024
1 parent 278423b commit 88ec368
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion faker/providers/color/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def __init__(self, generator: Optional["Generator"] = None, seed: Optional[SeedT
self.random = generator.random
else:
self.seed = seed if seed else random.randint(0, sys.maxsize)
self.random = random.Random(self.seed)
self.random = random.Random(int(self.seed))

def generate(
self,
Expand Down
7 changes: 5 additions & 2 deletions faker/providers/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def pydecimal(
self,
left_digits: Optional[int] = None,
right_digits: Optional[int] = None,
positive: bool = False,
positive: Optional[bool] = None,
min_value: Optional[BasicNumber] = None,
max_value: Optional[BasicNumber] = None,
) -> Decimal:
Expand Down Expand Up @@ -320,7 +320,10 @@ def pydecimal(
elif max_value is not None and max_value <= 0:
sign = "-"
else:
sign = "+" if positive else self.random_element(("+", "-"))
if positive is None:
sign = self.random_element(("+", "-"))
else:
sign = "+" if positive else "-"

if sign == "+":
if max_value is not None:
Expand Down

0 comments on commit 88ec368

Please sign in to comment.