Skip to content

Commit 41d9ffc

Browse files
jbittonfacebook-github-bot
authored andcommitted
fix linter workflow (#256)
Summary: Pull Request resolved: #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
1 parent 1ff16c8 commit 41d9ffc

File tree

14 files changed

+18
-82
lines changed

14 files changed

+18
-82
lines changed

.github/workflows/lint_python.yml

Lines changed: 2 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@ def overlay_wrap_text(
16541654
16551655
@param metadata : List to store metadata about the function execution
16561656
1657-
@returns: Image with text overlayed
1657+
@returns: Image with text overlaid
16581658
"""
16591659
rand = random.Random(random_seed)
16601660

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

20712071
image = imutils.validate_and_load_image(image)
20722072

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

21522152
image = imutils.validate_and_load_image(image)
21532153

augly/image/helpers.py

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 57 deletions
This file was deleted.

augly/tests/video_tests/transforms/composite_test.py

Lines changed: 1 addition & 2 deletions
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

0 commit comments

Comments
 (0)