Skip to content
Merged
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
11 changes: 4 additions & 7 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,13 @@ jobs:
python -m pip install .
python -m pip install -r requirements-dev.txt

- name: Lint with flake8
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
ruff check mapillary_tools

- name: Lint with black
- name: Format with ruff
run: |
black --check mapillary_tools tests
ruff format --check mapillary_tools tests

- name: Sort imports with usort
run: |
Expand Down
4 changes: 2 additions & 2 deletions mapillary_tools/mp4/mp4_sample_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def _extract_raw_samples(
if not chunk_entries:
return

assert len(sizes) <= len(
timedeltas
assert (
len(sizes) <= len(timedeltas)
), f"got less ({len(timedeltas)}) sample time deltas (stts) than expected ({len(sizes)})"

sample_idx = 0
Expand Down
4 changes: 2 additions & 2 deletions mapillary_tools/process_geotag_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _process_videos(


def _normalize_import_paths(
import_path: T.Union[Path, T.Sequence[Path]]
import_path: T.Union[Path, T.Sequence[Path]],
) -> T.Sequence[Path]:
import_paths: T.Sequence[Path]
if isinstance(import_path, Path):
Expand Down Expand Up @@ -283,7 +283,7 @@ def _process_videos_beta(vars_args: T.Dict):

options: CliOptions = {
"paths": vars_args["import_path"],
"recursive": vars_args["skip_subfolders"] == False,
"recursive": vars_args["skip_subfolders"] is False,
"geotag_sources_options": geotag_sources_opts,
"geotag_source_path": vars_args["geotag_source_path"],
"num_processes": vars_args["num_processes"],
Expand Down
2 changes: 1 addition & 1 deletion mapillary_tools/sample_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def wip_dir_context(wip_dir: Path, done_dir: Path, rename_timeout_sec: int = 10)
except Exception as e:
time.sleep(1)
error = e
if not renamed and not error is None:
if not renamed and error is not None:
raise error
else:
wip_dir.rename(done_dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import functools
import logging
import os
import sys
import typing as T
from pathlib import Path

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def extract_make(self) -> T.Optional[str]:
source_path = self.geotag_source_path
if not source_path:
return None
with source_path.open("rb") as fp:
with source_path.open("rb") as _fp:
return self.__camera_info[0] or None

def extract_model(self) -> T.Optional[str]:
source_path = self.geotag_source_path
if not source_path:
return None
with source_path.open("rb") as fp:
with source_path.open("rb") as _fp:
return self.__camera_info[1] or None
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def extract_points(self) -> T.Sequence[geo.Point]:
return []
try:
tracks = geotag_images_from_gpx_file.parse_gpx(path)
except Exception as e:
except Exception:
return []

points: T.Sequence[geo.Point] = sum(tracks, [])
Expand Down
3 changes: 1 addition & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Pillow; python_version>='3.8'
pytest
black
mypy
ruff
pyinstaller
flake8
types-requests
types-appdirs
usort
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_sequence_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ def test_duplication(tmpdir: py.path.local):
error_metadatas = [d for d in metadatas if isinstance(d, types.ErrorMetadata)]
assert len(error_metadatas) == 4
assert set(d.filename for d in sequence[1:-2]) == set(
Path(d.error.desc["filename"]) for d in error_metadatas # type: ignore
Path(d.error.desc["filename"])
for d in error_metadatas # type: ignore
)


Expand Down
Loading