Skip to content

Commit

Permalink
Python3.12 randint support
Browse files Browse the repository at this point in the history
  • Loading branch information
elecay committed Jan 25, 2024
1 parent 2107dd0 commit 0251386
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion jsf/schema_types/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def generate(self, context: Dict[str, Any]) -> Optional[List[Any]]:

output = [
self.items.generate(context)
for _ in range(random.randint(self.minItems, self.maxItems))
for _ in range(random.randint(int(self.minItems), int(self.maxItems)))
]
if self.uniqueItems and self.items.type == "object":
output = [dict(s) for s in {frozenset(d.items()) for d in output}]
Expand Down
2 changes: 1 addition & 1 deletion jsf/schema_types/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def generate(self, context: Dict[str, Any]) -> Optional[float]:
_max = self.maximum

return float(
step * random.randint(math.ceil(float(_min) / step), math.floor(float(_max) / step))
step * random.uniform(math.ceil(float(_min) / step), math.floor(float(_max) / step))
)

def model(self, context: Dict[str, Any]):
Expand Down
2 changes: 1 addition & 1 deletion jsf/schema_types/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def temporal_duration(


def mostly_zero_randint(_min: int, _max: int) -> int:
return 0 if random.random() > 0.8 else random.randint(_min, _max)
return 0 if random.random() > 0.8 else random.randint(int(_min), int(_max))


def fake_duration():
Expand Down

0 comments on commit 0251386

Please sign in to comment.