Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nosec B311 directives #1226

Merged
merged 1 commit into from
Dec 14, 2023
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
4 changes: 2 additions & 2 deletions src/datumaro/plugins/sampler/random_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(

def __iter__(self):
if self._indices is None:
rng = Random(self._seed)
rng = Random(self._seed) # nosec B311

if self._subset:
n = len(self._extractor.get_subset(self._subset))
Expand Down Expand Up @@ -214,7 +214,7 @@ def _make_bucket():

buckets = defaultdict(_make_bucket) # subset -> subset_buckets

rng = Random(self._seed)
rng = Random(self._seed) # nosec B311

for i, item in enumerate(self._extractor):
labels = set(getattr(ann, "label", None) for ann in item.annotations)
Expand Down
7 changes: 4 additions & 3 deletions src/datumaro/plugins/synthetic_data/image_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
with mp_ctx.Pool(processes=self._cpu_count) as pool:
try:
params = pool.map(
self._generate_category, [Random(i) for i in range(self._categories)]
self._generate_category,
[Random(i) for i in range(self._categories)], # nosec B311
)
finally:
pool.close()
Expand Down Expand Up @@ -125,7 +126,7 @@

for i, param, w in zip(indices, params, weights):
image = self._generate_image(
Random(i),
Random(i), # nosec B311
param,
self._iterations,
self._height,
Expand All @@ -134,7 +135,7 @@
weight=w,
)
color_image = colorize(image, net)
aug_image = augment(Random(i), color_image, background_colors)
aug_image = augment(Random(i), color_image, background_colors) # nosec B311

Check warning on line 138 in src/datumaro/plugins/synthetic_data/image_generator.py

View check run for this annotation

Codecov / codecov/patch

src/datumaro/plugins/synthetic_data/image_generator.py#L138

Added line #L138 was not covered by tests
save_image(
osp.join(self._output_dir, "{:06d}.png".format(i)), aug_image, create_dir=True
)
Expand Down
Loading