Skip to content

Commit b8f0b0c

Browse files
committed
lint
1 parent f9c9b16 commit b8f0b0c

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Local mirror of the CI lint gates (.github/workflows build):
2+
# Black --check -> black hook (auto-fixes on commit instead of failing)
3+
# flake8 blocking pass (E9,F63,F7,F82) -> flake8 hook
4+
#
5+
# One-time setup per clone:
6+
# brew install pre-commit (or: pip install pre-commit)
7+
# pre-commit install
8+
#
9+
# After that every `git commit` formats staged Python with Black and runs
10+
# the flake8 error gate; a commit can't leave the repo in a state CI would
11+
# reject. `pre-commit run --all-files` checks the whole tree on demand.
12+
repos:
13+
- repo: https://github.com/psf/black
14+
rev: 26.1.0
15+
hooks:
16+
- id: black
17+
- repo: https://github.com/pycqa/flake8
18+
rev: 7.1.1
19+
hooks:
20+
- id: flake8
21+
# CI's blocking selectors only — its second, style-wide flake8 pass
22+
# runs --exit-zero (advisory), so it is not enforced here either.
23+
args: ['--count', '--select=E9,F63,F7,F82', '--show-source']

datatorch/api/pull.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ def _select_datasets(project: dict, dataset_name: Optional[str]) -> list:
231231
if len(insensitive) == 1:
232232
return insensitive
233233
names = ", ".join(sorted(d.get("name", "?") for d in nodes)) or "(none)"
234-
raise PullError(
235-
f"Dataset '{dataset_name}' not found. Available datasets: {names}"
236-
)
234+
raise PullError(f"Dataset '{dataset_name}' not found. Available datasets: {names}")
237235

238236

239237
def _resolve_version(api: _PullSession, dataset: dict, version_name: str) -> dict:
@@ -292,9 +290,7 @@ def _list_version_files(api: _PullSession, version_id: str) -> list:
292290
{"id": version_id, "page": page, "perPage": PAGE_SIZE},
293291
)
294292
rows = [
295-
r
296-
for r in (_none_safe(data.get("datasetVersion")).get("files") or [])
297-
if r
293+
r for r in (_none_safe(data.get("datasetVersion")).get("files") or []) if r
298294
]
299295
for row in rows:
300296
files.append(
@@ -411,9 +407,7 @@ def _download_one(
411407
"Run 'datatorch login' (or set DATATORCH_API_KEY) "
412408
"and retry."
413409
)
414-
raise PullError(
415-
api._auth_hint(f"HTTP {r.status_code} on download")
416-
)
410+
raise PullError(api._auth_hint(f"HTTP {r.status_code} on download"))
417411
if r.status_code == 416:
418412
# Our .part is already >= the object; discard and re-fetch.
419413
_safe_remove(part)

datatorch/cli/main/pull.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def pull(path, dataset, version_name, out, workers, force, annotations_format, h
7878
def on_start(dataset_name: str, file_count: int):
7979
if progress["bar"] is not None:
8080
progress["bar"].close()
81-
click.echo(f"Dataset {click.style(dataset_name, bold=True)}: {file_count} file(s)")
81+
click.echo(
82+
f"Dataset {click.style(dataset_name, bold=True)}: {file_count} file(s)"
83+
)
8284
progress["bar"] = tqdm(total=file_count, unit="file") if file_count else None
8385

8486
def on_file_done(outcome: str):

0 commit comments

Comments
 (0)