Skip to content

Commit 5e00000

Browse files
jbittonfacebook-github-bot
authored andcommitted
fix linter workflow (facebookresearch#256)
Summary: Pull Request resolved: facebookresearch#256 our linter is finding some "vulnerabilities" which are intentional - e.g. the bidirectional unicode character which we use as part of our text attacks. skipping Reviewed By: joelicohk Differential Revision: D68521953 fbshipit-source-id: 207972838b7b02871580641fa8d810ab14b32924
1 parent decc9f3 commit 5e00000

14 files changed

+18
-82
lines changed

.github/workflows/lint_python.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v2
1212
- uses: actions/setup-python@v2
13-
- run: pip install bandit click==8.0.4 black==22.3.0 codespell flake8 isort pyre-check pytest pyupgrade safety
14-
- run: bandit --recursive --skip B101,B301,B303,B311,B324,B403 .
13+
- run: pip install bandit click==8.0.4 black==22.3.0 codespell flake8 isort pyre-check pytest pyupgrade
14+
- run: bandit --recursive --skip B101,B301,B303,B311,B324,B403,B613 .
1515
- run: black --check .
1616
- run: codespell --ignore-words-list="tha" --skip="*/text_tests,*assets/text/*,*examples/*,*/text/augmenters/utils.py"
1717
- run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
1818
- run: flake8 . --count --exit-zero --max-complexity=15 --max-line-length=90 --show-source --statistics
1919
- run: isort --check-only --profile black . || true
2020
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
21-
- run: safety check

.github/workflows/test_python.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
python-version: '3.9'
1515
- run: sudo apt-get update
1616
- run: sudo apt-get install --fix-missing ffmpeg python3-soundfile
17-
- run: pip install pyre-check pytest torchvision
17+
- run: pip install pyre-check pytest
1818
- run: pip install -e .[all]
1919
- run: pyre --source-directory "." --noninteractive check || true
2020
- run: pytest --durations=10 .

augly/image/functional.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ def overlay_wrap_text(
16551655
16561656
@param metadata : List to store metadata about the function execution
16571657
1658-
@returns: Image with text overlayed
1658+
@returns: Image with text overlaid
16591659
"""
16601660
rand = random.Random(random_seed)
16611661

@@ -2067,7 +2067,7 @@ def random_noise(
20672067
"""
20682068
assert type(mean) in [float, int], "Mean must be an integer or a float"
20692069
assert type(var) in [float, int], "Variance must be an integer or a float"
2070-
assert type(seed) == int, "Seed must be an integer"
2070+
assert type(seed) is int, "Seed must be an integer"
20712071

20722072
image = imutils.validate_and_load_image(image)
20732073

@@ -2147,8 +2147,8 @@ def resize(
21472147
21482148
@returns: the augmented PIL Image
21492149
"""
2150-
assert width is None or type(width) == int, "Width must be an integer"
2151-
assert height is None or type(height) == int, "Height must be an integer"
2150+
assert width is None or type(width) is int, "Width must be an integer"
2151+
assert height is None or type(height) is int, "Height must be an integer"
21522152

21532153
image = imutils.validate_and_load_image(image)
21542154

augly/image/helpers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def fit_text_in_bbox(
5858
5959
@param rand: Random number generator
6060
61-
@returns: x and y coordinates to start writing, text split into lines, line heigh, and font style
61+
@returns: x and y coordinates to start writing, text split into lines, line height, and font style
6262
"""
6363
x_min = int(img_width * 0.05) # reserves 5% on the left
6464
x_max = int(img_width * 0.5) # starts writing at the center of the image
@@ -77,7 +77,7 @@ def fit_text_in_bbox(
7777
_, _, _, line_height = font.getbbox("hg")
7878

7979
y_min = int(img_height * 0.05) # reserves 5% on the top
80-
y_max = int(img_height * 0.9) # reseves 10% to the bottom
80+
y_max = int(img_height * 0.9) # reserves 10% to the bottom
8181
y_max -= (
8282
len(lines) * line_height
8383
) # adjust max y-coordinate for text height and number of lines

augly/image/requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
numpy>=1.19.5
22
Pillow>=9.0.0
3-
torch>=1.9.0

augly/image/transforms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __call__(
5858
@returns: Augmented PIL Image
5959
"""
6060
assert isinstance(image, Image.Image), "Image passed in must be a PIL Image"
61-
assert type(force) == bool, "Expected type bool for variable `force`"
61+
assert type(force) is bool, "Expected type bool for variable `force`"
6262

6363
if not force and random.random() > self.p:
6464
return image
@@ -1525,7 +1525,7 @@ def __init__(
15251525
15261526
@param p: the probability of the transform being applied; default value is 1.0
15271527
1528-
@returns: Image with text overlayed
1528+
@returns: Image with text overlaid
15291529
"""
15301530
super().__init__(p)
15311531
self.text, self.color = text, color

augly/tests/audio_tests/functional_unit_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
import unittest
99

10-
from aml.augly.tests.audio_tests.base_unit_test import BaseAudioUnitTest
11-
1210
from augly import audio as audaugs
11+
from augly.tests.audio_tests.base_unit_test import BaseAudioUnitTest
1312

1413

1514
class FunctionalAudioUnitTest(BaseAudioUnitTest):

augly/tests/audio_tests/transforms_unit_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import unittest
1111

1212
import numpy as np
13-
from aml.augly.tests.audio_tests.base_unit_test import BaseAudioUnitTest
1413
from augly import audio as audaugs
14+
from augly.tests.audio_tests.base_unit_test import BaseAudioUnitTest
1515
from augly.utils import AUDIO_METADATA_PATH
1616

1717

augly/tests/image_tests/pytorch_test.py

-57
This file was deleted.

augly/tests/video_tests/transforms/composite_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
import random
1010
import unittest
1111

12-
from aml.augly.tests.video_tests.base_unit_test import BaseVideoUnitTest
13-
1412
from augly import audio as audaugs, video as vidaugs
1513
from augly.tests.base_configs import VideoAugConfig
14+
from augly.tests.video_tests.base_unit_test import BaseVideoUnitTest
1615
from augly.utils import VIDEO_METADATA_PATH
1716
from augly.utils.ffmpeg import get_conditional_for_skipping_video_tests
1817

augly/tests/video_tests/transforms/cv2_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import json
99
import unittest
1010

11-
from aml.augly.tests.video_tests.base_unit_test import BaseVideoUnitTest
12-
1311
from augly import video as vidaugs
12+
from augly.tests.video_tests.base_unit_test import BaseVideoUnitTest
1413
from augly.utils import VIDEO_METADATA_PATH
1514

1615

augly/tests/video_tests/transforms/ffmpeg_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import json
99
import unittest
1010

11-
from aml.augly.tests.video_tests.base_unit_test import BaseVideoUnitTest
12-
1311
from augly import video as vidaugs
1412
from augly.tests.base_configs import VideoAugConfig
13+
from augly.tests.video_tests.base_unit_test import BaseVideoUnitTest
1514
from augly.utils import VIDEO_METADATA_PATH
1615

1716

augly/tests/video_tests/transforms/image_based_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import json
99
import unittest
1010

11-
from aml.augly.tests.video_tests.base_unit_test import BaseVideoUnitTest
12-
1311
from augly import video as vidaugs
1412
from augly.tests.base_configs import VideoAugConfig
13+
from augly.tests.video_tests.base_unit_test import BaseVideoUnitTest
1514
from augly.utils import VIDEO_METADATA_PATH
1615
from augly.utils.ffmpeg import get_conditional_for_skipping_video_tests
1716

augly/video/augmenters/cv2/text.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(
5858
fontscales[0] > 0 and fontscales[1] > fontscales[0]
5959
), "Fontscale ranges must be greater than zero and the second value must be greater than the first" # noqa: B950
6060
assert thickness is None or (
61-
type(thickness) == int and thickness > 0
61+
type(thickness) is int and thickness > 0
6262
), "Invalid thickness provided: must be set to None or be an integer greater than zero" # noqa: B950
6363

6464
super().__init__(1, random_movement, topleft, bottomright, **kwargs)

0 commit comments

Comments
 (0)