Skip to content

Commit

Permalink
Fix precommit (#3879)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wovchena authored Dec 5, 2023
1 parent 1a568fe commit 12052d7
Show file tree
Hide file tree
Showing 39 changed files with 50 additions and 50 deletions.
1 change: 1 addition & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ yaml-files:
# which yamllint complains about.

ignore: |
ci/bandit.yml
demos/thirdparty/
tools/accuracy_checker/dataset_definitions.yml
tools/accuracy_checker/configs/
Expand Down
1 change: 0 additions & 1 deletion .bandit → ci/bandit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

### This config may optionally select a subset of tests to run or skip by
### filling out the 'tests' and 'skips' lists given below. If no tests are
### specified for inclusion then it is assumed all tests are desired. The skips
Expand Down
4 changes: 2 additions & 2 deletions ci/check-basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"""

import re
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import sys

from pathlib import Path
Expand Down Expand Up @@ -150,7 +150,7 @@ def complain(message):
all_passed = False

print('running bandit...', flush=True)
if subprocess.run([sys.executable, '-m', 'bandit', '.', '-r', '-c', '.bandit'], cwd=OMZ_ROOT).returncode != 0:
if subprocess.run([sys.executable, '-m', 'bandit', '-r', '-c', 'ci/bandit.yml', '.'], cwd=OMZ_ROOT).returncode != 0:
all_passed = False

print('running documentation checks...', flush=True)
Expand Down
2 changes: 1 addition & 1 deletion ci/get-jobs-for-changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import argparse
import json
import re
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import sys

from pathlib import Path, PurePosixPath
Expand Down
2 changes: 1 addition & 1 deletion ci/prepare-documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import sys
import urllib.parse
import urllib.request
import xml.etree.ElementTree as ET # nosec - disable B405:import-xml-etree check
import xml.etree.ElementTree as ET # nosec B405 # disable import-xml-etree check

from pathlib import Path

Expand Down
2 changes: 1 addition & 1 deletion ci/prepare-openvino-content.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""

import argparse
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check

from pathlib import Path, PurePath

Expand Down
2 changes: 1 addition & 1 deletion demos/common/python/html_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_paragraphs(url_list):
paragraphs_all = []
for url in url_list:
log.debug("Get paragraphs from {}".format(url))
with urllib.request.urlopen(url) as response: # nosec - disable B310:urllib-urlopen check
with urllib.request.urlopen(url) as response: # nosec B310 # disable urllib-urlopen check
parser = HTMLDataExtractor(['title', 'p'])
charset='utf-8'
if 'Content-type' in response.headers:
Expand Down
2 changes: 1 addition & 1 deletion demos/common/python/visualizers/drawing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, n, rng=None):
if n == 0:
raise ValueError('ColorPalette accepts only the positive number of colors')
if rng is None:
rng = random.Random(0xACE) # nosec - disable B311:random check
rng = random.Random(0xACE) # nosec B311 # disable random check

candidates_num = 100
hsv_colors = [(1.0, 1.0, 1.0)]
Expand Down
2 changes: 1 addition & 1 deletion demos/formula_recognition_demo/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging as log
import os
import re
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import tempfile
from enum import Enum
from multiprocessing.pool import ThreadPool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def update(self, feature_vec):
self.clusters.append(feature_vec)
self.clusters_sizes.append(1)
elif sum(self.clusters_sizes) < 2*self.feature_len:
idx = random.randint(0, self.feature_len - 1) # nosec - disable B311:random check
idx = random.randint(0, self.feature_len - 1) # nosec B311 # disable random check
self.clusters_sizes[idx] += 1
self.clusters[idx] += (feature_vec - self.clusters[idx]) / \
self.clusters_sizes[idx]
Expand Down
4 changes: 2 additions & 2 deletions demos/tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import os
import shlex
import ssl
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import sys
import tempfile
import timeit
Expand Down Expand Up @@ -245,7 +245,7 @@ def main():
no_verify_because_of_windows = ssl.create_default_context()
no_verify_because_of_windows.check_hostname = False
no_verify_because_of_windows.verify_mode = ssl.CERT_NONE
with urlopen(COCO128_URL, context=no_verify_because_of_windows) as zipresp: # nosec - disable B310: urllib_urlopen because url is hardcoded
with urlopen(COCO128_URL, context=no_verify_because_of_windows) as zipresp: # nosec B310 # disable urllib_urlopen because url is hardcoded
with ZipFile(BytesIO(zipresp.read())) as zfile:
zfile.extractall(args.test_data_dir)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import argparse
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import sys

from pathlib import Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import argparse
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import sys

from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion models/public/mozilla-deepspeech-0.8.2/pre-convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
import sys
import argparse
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check

from pathlib import Path

Expand Down
2 changes: 1 addition & 1 deletion models/public/ocrnet-hrnet-w48-paddle/pre-convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import argparse
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import sys

from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion models/public/yolo-v2-tiny-tf/pre-convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import argparse
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import sys

from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion models/public/yolo-v4-tf/pre-convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import argparse
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import sys

from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion models/public/yolo-v4-tiny-tf/pre-convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import argparse
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import sys

from pathlib import Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import os
import struct
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import tempfile
from pathlib import Path
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
"""

import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
from pathlib import Path
import numpy as np

Expand All @@ -38,9 +38,9 @@ def __init__(self, source,
self.source = open(source, 'r', encoding='UTF-8') # pylint: disable=R1732
self.source_dicts = []
for source_dict in [uid_voc, mid_voc, cat_voc]:
# disable B301:pickle check
with open(source_dict, 'rb') as source_content:
self.source_dicts.append(pickle.load(source_content, encoding='UTF-8')) # nosec
# disable pickle check
self.source_dicts.append(pickle.load(source_content, encoding='UTF-8')) # nosec B301

with open(item_info, "r", encoding='UTF-8') as f_meta:
meta_map = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import copy
import json
from pathlib import Path
import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
from argparse import ArgumentParser
from collections import namedtuple
from functools import partial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
"""

import pickle as pkl # nosec - disable B403:import-pickle check
import pickle as pkl # nosec B403 # disable import-pickle check
import json
from .format_converter import DirectoryBasedAnnotationConverter, ConverterReturn
from ..representation import CharacterRecognitionAnnotation
Expand All @@ -36,7 +36,7 @@ def read_vocab(vocab_path):
"""
if vocab_path.suffix == '.pkl':
with open(vocab_path, "rb") as f:
vocab_dict = pkl.load(f) # nosec - disable B301: pickle load check
vocab_dict = pkl.load(f) # nosec B301 # disable pickle load check
elif vocab_path.suffix == '.json':
with open(vocab_path, "r", encoding='UTF-8') as f:
vocab_dict = json.load(f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
"""

import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
from collections import defaultdict
from pathlib import Path

Expand Down Expand Up @@ -166,7 +166,7 @@ def configure(self):

def convert(self, check_content=False, progress_callback=None, progress_interval=100, **kwargs):
with self.bin_file.open('rb') as f:
bins, issame_list = pickle.load(f, encoding='bytes') # nosec - disable B301:pickle check
bins, issame_list = pickle.load(f, encoding='bytes') # nosec B301 # disable pickle check
annotations = []
content_errors = None if not check_content else []
num_iterations = len(issame_list) * 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pathlib import Path
from collections import OrderedDict
import warnings
import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
import numpy as np
import yaml

Expand Down Expand Up @@ -383,7 +383,7 @@ def read_annotation(annotation_file: Path, log=True):
annotation_file = Path(annotation_file)

result = []
loader_cls = pickle.Unpickler # nosec - disable B301:pickle check
loader_cls = pickle.Unpickler # nosec B301 # disable pickle check
with annotation_file.open('rb') as file:
loader = loader_cls(file)
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""

from pathlib import Path
import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
from functools import partial
from collections import OrderedDict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""

from pathlib import Path
import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
from collections import OrderedDict
import numpy as np

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
"""

import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
from collections import OrderedDict
from pathlib import Path

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""

from pathlib import Path
import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
from functools import partial
import numpy as np

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""

import copy
import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
import platform
from pathlib import Path
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from .loader import Loader, StoredPredictionBatch

from .pickle_loader import PickleLoader # nosec - disable B403:import-pickle check
from .pickle_loader import PickleLoader # nosec B403 # disable import-pickle check
from .xml_loader import XMLLoader
from .json_loader import JSONLoader

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
"""

import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check
from .loader import Loader, DictLoaderMixin, StoredPredictionBatch


Expand Down Expand Up @@ -54,7 +54,7 @@ def read_pickle(data_path):
with open(data_path, 'rb') as content:
while True:
try:
result.append(pickle.load(content)) # nosec - disable B301:pickle check
result.append(pickle.load(content)) # nosec B301 # disable pickle check
except EOFError:
break
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ More detailed information about calculation segmentation metrics you can find [h
* `psnr` - [Peak signal to noise ratio](https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio). Metric is calculated as a decibel(dB). Direction of metric's mean growth is higher-better. Direction of metric's std and max_error growth is higher-worse. Supported representations: `SuperResolutionAnnotation`, `SuperResolutionPrediction`, `ImageProcessingAnnotation`, `ImageProcessingPrediction`, `ImageInpaintingAnnotation`, `ImageInpaintingPrediction`.
* `color_order` - the field specified which color order `BGR` or `RGB` will be used during metric calculation (Optional. Default value is RGB), used only if you have 3-channel images.
* `normalized_images` - whether the images are normalized in [0, 1] range or not. Optional, default `False`.
* `scale_border` - Scale boarder - the number of pixels to crop from the height and width of the image. Optional, default value 4.
* `scale_border` - Scale boarder - the number of pixels to crop from the height and width of the image. Optional, default value 4.
* `unweighted_average` - whether metric is calculated as for grayscale image or not (3-channel images by default use weighted average of R, G, B channels). Optional, defaul value 'False'.
* `psnr-b` - [Peak signal to noise ratio with blocked effect factor](https://link.springer.com/chapter/10.1007/978-3-642-34595-1_16). Metric is calculated as a decibel(dB). Direction of metric's mean growth is higher-better. Direction of metric's std and max_error growth is higher-worse. Supported representations: `SuperResolutionAnnotation`, `SuperResolutionPrediction`, `ImageProcessingAnnotation`, `ImageProcessingPrediction`, `ImageInpaintingAnnotation`, `ImageInpaintingPrediction`.
* `color_order` - the field specified which color order `BGR` or `RGB` will be used during metric calculation (Optional. Default value is RGB), used only if you have 3-channel images.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
import logging
import os
import re
import subprocess # nosec - disable B404:import-subprocess check
import subprocess # nosec B404 # disable import-subprocess check
import tempfile
from multiprocessing import cpu_count
from multiprocessing.dummy import Pool as ThreadPool
from threading import Timer
from subprocess import PIPE # nosec - disable B404:import-subprocess check
from subprocess import PIPE # nosec B404 # disable import-subprocess check
from pathlib import Path

import cv2 as cv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""

import abc
import pickle # nosec - disable B403:import-pickle check
import pickle # nosec B403 # disable import-pickle check


class BaseRepresentation(abc.ABC):
Expand All @@ -26,7 +26,7 @@ def __init__(self, identifier, metadata=None):
@classmethod
def load(cls, file, loader=None):
if loader is None:
loader = pickle.Unpickler(file) # nosec - disable B301:pickle check
loader = pickle.Unpickler(file) # nosec B301 # disable pickle check
obj = loader.load()

if cls != BaseRepresentation:
Expand Down
Loading

0 comments on commit 12052d7

Please sign in to comment.