Skip to content
Closed
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: 1 addition & 1 deletion lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pip-missing-reqs:

.PHONY: pylint
pylint:
pylint *.py src/ tests/ docs/ ci/
python -m pylint *.py src/ tests/ docs/ ci/

.PHONY: pyroma
pyroma:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ dependencies = [
"flask",
"multipart",
"numpy",
"opencv-python",
"opencv-python>=4.8.1.78",
"pydantic-settings",
"requests",
"requests-mock",
Expand Down Expand Up @@ -304,7 +304,7 @@ dev = [
"pip_check_reqs==2.5.3",
"pydocstyle==6.3.0",
"pyenchant==3.2.2",
"pylint==2.17.7",
"pylint==3.0.0",
"pyright==1.1.329",
"pyroma==4.2",
"pytest-cov==4.1.0",
Expand Down
12 changes: 5 additions & 7 deletions src/mock_vws/target_raters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
import numpy as np
from PIL import Image

# cv2 errors cannot be inferred without type stubs.
# See https://github.com/opencv/opencv/issues/14590.
_CV2_ERROR = (
cv2.error # pyright: ignore[reportGeneralTypeIssues] # pylint: disable=no-member
)


@functools.cache
def _get_brisque_target_tracking_rating(image_content: bytes) -> int:
Expand All @@ -38,7 +32,11 @@ def _get_brisque_target_tracking_rating(image_content: bytes) -> int:
with np.errstate(divide="ignore", invalid="ignore"):
try:
score = brisque_obj.score(img=image_array)
except (_CV2_ERROR, ValueError):
# pylint is not aware of `python-opencv`'s error hierarchy.
except ( # pylint: disable=catching-non-exception
cv2.error,
ValueError,
):
return 0
if math.isnan(score):
return 0
Expand Down
6 changes: 4 additions & 2 deletions tests/mock_vws/test_requests_mock_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ def test_to_dict(high_quality_image: io.BytesIO) -> None:
application_metadata=None,
)

(target,) = database.targets
assert len(database.targets) == 1
target = next(iter(database.targets))
target_dict = target.to_dict()

# The dictionary is JSON dump-able
Expand Down Expand Up @@ -304,7 +305,8 @@ def test_to_dict_deleted(high_quality_image: io.BytesIO) -> None:
vws_client.wait_for_target_processed(target_id=target_id)
vws_client.delete_target(target_id=target_id)

(target,) = database.targets
assert len(database.targets) == 1
target = next(iter(database.targets))
target_dict = target.to_dict()

# The dictionary is JSON dump-able
Expand Down