chore: add ruff + mypy + CI tooling (and fix a pyarrow NameError)#120
Merged
Conversation
Configure ruff (pyflakes/import/statement rules, blocking in CI) and mypy (advisory), add a dev extra and GitHub Actions workflow. Fix issues surfaced: a real bug where 'except (OSError, pyarrow.ArrowInvalid)' raised NameError (pyarrow was never imported, only pyarrow.parquet as pq), plus unused imports/vars, empty f-strings, and bare excepts.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sets up linting, type-checking, and CI — and fixes the real bug the linter immediately surfaced.
Real bug found by linting
download.pycaughtexcept (OSError, pyarrow.ArrowInvalid)in 5 places, but onlyimport pyarrow.parquet as pqwas present —pyarrowwas never bound. So whenever a corrupt parquet raisedArrowInvalid, the handler itself raisedNameErrorinstead of catching it. Fixed by importingpyarrow.Tooling
[tool.ruff]): baseline rulesetE4,E7,E9,F— pyflakes (real bugs) plus import/statement errors. Style rules left off for now to keep the diff focused. Blocking in CI.[tool.mypy]): lenient config (ignore_missing_imports). Advisory in CI (continue-on-error) — the codebase is ~30% typed, so it reports without blocking until coverage improves.pip install -e .[dev]now pulls pytest/ruff/mypy (previously no test dep was declared anywhere)..github/workflows/ci.yml):lint(blocking) +typecheck(advisory) on push/PR to dev/main.Lint fixes applied to reach a clean baseline
pyarrowimport (above).except:→except Exception:(4 sites in archive.py/media.py — they were swallowing KeyboardInterrupt/SystemExit).df = await run_*_benchmark(...)captures).x = lambda→defin download.py.All mechanical; no behavior change except the pyarrow fix and the bare-except narrowing.
Verification
ruff check src tests→ clean.pyarrow.ArrowInvalidnow resolves.test_config_loadingfailures.Deliberately out of scope (next step)
No test job in CI yet, for two reasons that need your call:
test_config_loadingtests are stale/brittle —m4aandmovare valid formats (they're indownload.py's extension sets), and the count/membership tests hardcode values that drift on every data change. Fixing them means deciding what they should assert.Happy to follow up: fix the stale tests (derive format validity from the real extension constants; make the count tests robust) and add a blocking test job.