Skip to content

Commit 8dec895

Browse files
authored
CI: replace flake/black with ruff (#691)
* ruff check mapillary_tools --fix * ruff format mapillary_tools tests * update the CI * update requirements-dev.txt
1 parent 68e5e31 commit 8dec895

File tree

9 files changed

+15
-19
lines changed

9 files changed

+15
-19
lines changed

.github/workflows/python-package.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,13 @@ jobs:
6767
python -m pip install .
6868
python -m pip install -r requirements-dev.txt
6969
70-
- name: Lint with flake8
70+
- name: Lint with ruff
7171
run: |
72-
# stop the build if there are Python syntax errors or undefined names
73-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
74-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
75-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
72+
ruff check mapillary_tools
7673
77-
- name: Lint with black
74+
- name: Format with ruff
7875
run: |
79-
black --check mapillary_tools tests
76+
ruff format --check mapillary_tools tests
8077
8178
- name: Sort imports with usort
8279
run: |

mapillary_tools/mp4/mp4_sample_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def _extract_raw_samples(
5959
if not chunk_entries:
6060
return
6161

62-
assert len(sizes) <= len(
63-
timedeltas
62+
assert (
63+
len(sizes) <= len(timedeltas)
6464
), f"got less ({len(timedeltas)}) sample time deltas (stts) than expected ({len(sizes)})"
6565

6666
sample_idx = 0

mapillary_tools/process_geotag_properties.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _process_videos(
170170

171171

172172
def _normalize_import_paths(
173-
import_path: T.Union[Path, T.Sequence[Path]]
173+
import_path: T.Union[Path, T.Sequence[Path]],
174174
) -> T.Sequence[Path]:
175175
import_paths: T.Sequence[Path]
176176
if isinstance(import_path, Path):
@@ -283,7 +283,7 @@ def _process_videos_beta(vars_args: T.Dict):
283283

284284
options: CliOptions = {
285285
"paths": vars_args["import_path"],
286-
"recursive": vars_args["skip_subfolders"] == False,
286+
"recursive": vars_args["skip_subfolders"] is False,
287287
"geotag_sources_options": geotag_sources_opts,
288288
"geotag_source_path": vars_args["geotag_source_path"],
289289
"num_processes": vars_args["num_processes"],

mapillary_tools/sample_video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def wip_dir_context(wip_dir: Path, done_dir: Path, rename_timeout_sec: int = 10)
167167
except Exception as e:
168168
time.sleep(1)
169169
error = e
170-
if not renamed and not error is None:
170+
if not renamed and error is not None:
171171
raise error
172172
else:
173173
wip_dir.rename(done_dir)

mapillary_tools/video_data_extraction/extractors/base_parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import functools
33
import logging
44
import os
5-
import sys
65
import typing as T
76
from pathlib import Path
87

mapillary_tools/video_data_extraction/extractors/camm_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ def extract_make(self) -> T.Optional[str]:
3131
source_path = self.geotag_source_path
3232
if not source_path:
3333
return None
34-
with source_path.open("rb") as fp:
34+
with source_path.open("rb") as _fp:
3535
return self.__camera_info[0] or None
3636

3737
def extract_model(self) -> T.Optional[str]:
3838
source_path = self.geotag_source_path
3939
if not source_path:
4040
return None
41-
with source_path.open("rb") as fp:
41+
with source_path.open("rb") as _fp:
4242
return self.__camera_info[1] or None

mapillary_tools/video_data_extraction/extractors/gpx_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def extract_points(self) -> T.Sequence[geo.Point]:
1616
return []
1717
try:
1818
tracks = geotag_images_from_gpx_file.parse_gpx(path)
19-
except Exception as e:
19+
except Exception:
2020
return []
2121

2222
points: T.Sequence[geo.Point] = sum(tracks, [])

requirements-dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
Pillow; python_version>='3.8'
22
pytest
3-
black
43
mypy
4+
ruff
55
pyinstaller
6-
flake8
76
types-requests
87
types-appdirs
98
usort

tests/unit/test_sequence_processing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ def test_duplication(tmpdir: py.path.local):
231231
error_metadatas = [d for d in metadatas if isinstance(d, types.ErrorMetadata)]
232232
assert len(error_metadatas) == 4
233233
assert set(d.filename for d in sequence[1:-2]) == set(
234-
Path(d.error.desc["filename"]) for d in error_metadatas # type: ignore
234+
Path(d.error.desc["filename"])
235+
for d in error_metadatas # type: ignore
235236
)
236237

237238

0 commit comments

Comments
 (0)