Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ ignore = [
# narrowing - see
# https://mypy.readthedocs.io/en/stable/type_narrowing.html#type-narrowing-expressions.
"S101",
# Allow `random` as we are not implementing something which needs cryptographic safety.
"S311",
]

# Do not automatically remove commented out code.
Expand Down
4 changes: 2 additions & 2 deletions src/mock_vws/target_raters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import functools
import io
import math
import random
import secrets
from typing import Protocol, runtime_checkable

import piq # type: ignore[import-untyped]
Expand Down Expand Up @@ -62,7 +62,7 @@ def __call__(self, image_content: bytes) -> int:
image_content: A target's image's content.
"""
assert image_content
return random.randint(0, 5)
return secrets.randbelow(exclusive_upper_bound=6)


class HardcodedTargetTrackingRater:
Expand Down
8 changes: 4 additions & 4 deletions tests/mock_vws/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import io
import random
import secrets
from typing import Literal

import requests
Expand Down Expand Up @@ -89,9 +89,9 @@ def make_image_file(
image = Image.new(color_space, (width, height))
for row_index in range(height):
for column_index in range(width):
red = random.choice(seq=range(255))
green = random.choice(seq=range(255))
blue = random.choice(seq=range(255))
red = secrets.choice(seq=range(255))
green = secrets.choice(seq=range(255))
blue = secrets.choice(seq=range(255))
image.putpixel(
xy=(column_index, row_index),
value=(red, green, blue),
Expand Down