Skip to content

Commit

Permalink
Fixed long-stanidng ruff linter issues (#859)
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie committed Jun 7, 2024
1 parent f81d4e7 commit ad77b9f
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion darwin/backend_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def wrapper(self, *args, **kwargs) -> Callable:


class BackendV2:
def __init__(self, client: "Client", default_team):
def __init__(self, client: "Client", default_team): # noqa F821
self._client = client
self._default_team = default_team

Expand Down
2 changes: 1 addition & 1 deletion darwin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ def _raise_if_known_error(self, response: Response, url: str) -> None:
error_code: Optional[str] = None
try:
error_code = response.json()["errors"]["code"]
except:
except Exception:
pass

if error_code == "INSUFFICIENT_REMAINING_STORAGE":
Expand Down
4 changes: 2 additions & 2 deletions darwin/dataset/remote_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ def pull(
):
# will raise if not installed via pip install darwin-py[ocv]
try:
from cv2 import (
VideoCapture, # pylint: disable=import-outside-toplevel
from cv2 import ( # pylint: disable=import-outside-toplevel # noqa F401
VideoCapture,
)
except ImportError as e:
raise MissingDependency(
Expand Down
2 changes: 1 addition & 1 deletion darwin/dataset/remote_dataset_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def fetch_remote_files(
"item_paths",
]:
if list_type in filters:
if type(filters[list_type]) is list:
if isinstance(filters[list_type], list):
for value in filters[list_type]:
post_filters.append(("{}[]".format(list_type), value))
else:
Expand Down
2 changes: 1 addition & 1 deletion darwin/exporter/formats/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
try:
from numpy.typing import NDArray
except ImportError:
NDArray = Any # type:ignore
NDArray = Any # type:ignore # noqa F821
from PIL import Image
from upolygon import draw_polygon

Expand Down
2 changes: 1 addition & 1 deletion darwin/importer/formats/csv_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def parse_path(path: Path) -> Optional[List[dt.AnnotationFile]]:
continue
annotations = [dt.make_tag(tag) for tag in tags if len(tag) > 0]
if filename not in tags_and_files:
tags_and_files[filename] = [annotation for annotation in annotations]
tags_and_files[filename] = list(annotations)
else:
tags_and_files[filename].extend(annotations)

Expand Down
2 changes: 1 addition & 1 deletion darwin/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .flatten_list import flatten_list
from .utils import *
from .utils import * # noqa F403
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ warn_required_dynamic_aliases = true
warn_untyped_fields = true

[tool.ruff]
ignore = ["E203", "E402", "E501"]
lint.ignore = ["E203", "E402", "E501", "C901"]
line-length = 88
select = ["E", "F", "C"]
lint.select = ["E", "F", "C"]

[tool.flake8]
ignore = ["E203", "W503", "E402"]
Expand Down Expand Up @@ -92,7 +92,7 @@ test = ["responses", "pytest", "flake8-pyproject"]
[tool.poetry.scripts]
darwin = "darwin.cli:main"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"**/{tests,docs,tools}/*" = ["E402", "F403"]
"__init__.py" = ["E402", "F401"]

Expand Down
2 changes: 2 additions & 0 deletions tests/darwin/dataset/release_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import shutil
from pathlib import Path
from unittest.mock import patch

import pytest
import requests

from darwin.dataset.release import Release
Expand Down
1 change: 1 addition & 0 deletions tests/darwin/dataset/remote_dataset_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
import types
from datetime import datetime
from pathlib import Path
Expand Down
3 changes: 2 additions & 1 deletion tests/darwin/dataset/split_manager_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from pathlib import Path

import numpy as np
import pytest
Expand Down Expand Up @@ -71,6 +72,6 @@ def test_should_split_a_dataset(

for size, name in zip(sizes, names):
with open(splits / f"random_{name}.txt", "r") as f:
lines_len = len([l for l in f.readlines() if l.strip() != ""])
lines_len = len([line for line in f.readlines() if line.strip() != ""])
local_size = lines_len / tot_size, size
assert np.allclose(local_size, size, atol=1e-3)
2 changes: 1 addition & 1 deletion tests/darwin/exporter/formats/export_mask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
try:
from numpy.typing import NDArray
except ImportError:
NDArray = Any # type:ignore
NDArray = Any # type:ignore # noqa F821

from darwin import datatypes as dt
from darwin.exporter.formats.mask import (
Expand Down
1 change: 1 addition & 0 deletions tests/darwin/importer/formats/import_nifti_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from zipfile import ZipFile

import numpy as np
import pytest
from scipy import ndimage

from darwin.datatypes import (
Expand Down

0 comments on commit ad77b9f

Please sign in to comment.