Lint python
This commit is contained in:
parent
a2e4c29839
commit
86690f41f1
7 changed files with 1367 additions and 17 deletions
28
.github/workflows/lint.yml
vendored
Normal file
28
.github/workflows/lint.yml
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
name: Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v4
|
||||
|
||||
- name: Set up Python
|
||||
run: uv python install
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync
|
||||
|
||||
- name: Check linting
|
||||
run: uv run ruff check .
|
||||
|
||||
- name: Check formatting
|
||||
run: uv run ruff format --check .
|
||||
|
|
@ -49,3 +49,9 @@ tasks:
|
|||
desc: Run production server (serves built frontend)
|
||||
cmds:
|
||||
- uv run fastapi run server/main.py --port 8001
|
||||
|
||||
lint:
|
||||
desc: Lint and format Python code
|
||||
cmds:
|
||||
- uv run ruff check --fix .
|
||||
- uv run ruff format .
|
||||
|
|
|
|||
|
|
@ -35,13 +35,16 @@ def download_with_progress(url: str, output_path: Path) -> None:
|
|||
response.raise_for_status() # pyright: ignore[reportUnusedCallResult]
|
||||
total = int(response.headers.get("content-length", 0))
|
||||
|
||||
with open(output_path, "wb") as f, tqdm(
|
||||
with (
|
||||
open(output_path, "wb") as f,
|
||||
tqdm(
|
||||
total=total,
|
||||
unit="B",
|
||||
unit_scale=True,
|
||||
unit_divisor=1024,
|
||||
desc="Downloading",
|
||||
) as pbar:
|
||||
) as pbar,
|
||||
):
|
||||
for chunk in response.iter_bytes(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
pbar.update(len(chunk))
|
||||
|
|
|
|||
|
|
@ -35,13 +35,16 @@ def download_with_progress(url: str, output_path: Path) -> None:
|
|||
response.raise_for_status() # pyright: ignore[reportUnusedCallResult]
|
||||
total = int(response.headers.get("content-length", 0))
|
||||
|
||||
with open(output_path, "wb") as f, tqdm(
|
||||
with (
|
||||
open(output_path, "wb") as f,
|
||||
tqdm(
|
||||
total=total,
|
||||
unit="B",
|
||||
unit_scale=True,
|
||||
unit_divisor=1024,
|
||||
desc="Downloading",
|
||||
) as pbar:
|
||||
) as pbar,
|
||||
):
|
||||
for chunk in response.iter_bytes(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
pbar.update(len(chunk))
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
# Run it with:
|
||||
# uv run generate_tfl_client.py
|
||||
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
|
@ -28,7 +27,14 @@ def main() -> None:
|
|||
# Generate the client
|
||||
print(f"Generating client from {OPENAPI_SPEC}")
|
||||
result = subprocess.run(
|
||||
["openapi-python-client", "generate", "--path", str(OPENAPI_SPEC), "--output-path", str(OUTPUT_PATH)],
|
||||
[
|
||||
"openapi-python-client",
|
||||
"generate",
|
||||
"--path",
|
||||
str(OPENAPI_SPEC),
|
||||
"--output-path",
|
||||
str(OUTPUT_PATH),
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ requires-python = ">=3.12"
|
|||
dependencies = [
|
||||
"attrs>=22.2.0",
|
||||
"httpx>=0.28.1",
|
||||
"ipywidgets>=8.0.0",
|
||||
"journey-client",
|
||||
"jupyter>=1.0.0",
|
||||
"nest-asyncio>=1.6.0",
|
||||
"numpy>=1.26.0",
|
||||
"pandas>=2.0.0",
|
||||
"plotly>=6.5.2",
|
||||
|
|
@ -20,5 +23,8 @@ dependencies = [
|
|||
"h3>=3.7.0",
|
||||
]
|
||||
|
||||
[dependency-groups]
|
||||
dev = ["ruff>=0.8.0"]
|
||||
|
||||
[tool.uv.sources]
|
||||
journey-client = { path = "./tfl_journey_client" }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue