Skip to content

fix(raw): _format_args sostituisce {year} anche su path normalizzati Path - #461

Merged
Gabrymi93 merged 2 commits into
mainfrom
fix/raw-format-args-path-year
Aug 9, 2026
Merged

fix(raw): _format_args sostituisce {year} anche su path normalizzati Path#461
Gabrymi93 merged 2 commits into
mainfrom
fix/raw-format-args-path-year

Conversation

@Gabrymi93

Copy link
Copy Markdown
Member

Tipo

root fix_format_args non sostituiva {year} sui path normalizzati a PosixPath.

Problema reale

_normalize_paths converte raw.sources[].args.path (tipo local_file) in PosixPath. _format_args gestiva la sostituzione di {year} solo su valori str — i path Path con placeholder restavano non sostituiti, facendo fallire i seed locali con {year} nel percorso.

Contratto riusato/sostituito

  • Riusato: la logica {year}str(year) già esistente per le stringhe (replace, non str.format, per non confliggere con {} di SPARQL).
  • Sostituito: il branch if isinstance(v, str) ora gestisce anche Path.

Implementazione

File Cosa
toolkit/raw/_fetch_utils.py Branch Path in _format_args: sostituisce {year} su str(v), ri-costruisce Path; path senza placeholder restituito invariato (stesso tipo)
tests/test_raw_run_format_args.py 2 test: path con {year} sostituito, path senza {year} invariato

Verifica

  • 11 test verdi (file), 1329+ totali, ruff pulito.
  • Comportamento: Path("/repo/_local/seed/dati/{year}/ETA_{year}.CSV")Path(".../dati/2024/ETA_2024.CSV"); path senza placeholder → Path invariato.

Rischio residuo

Nessuno — fix mirato a un tipo di valore (Path) del branch esistente.

Follow-up

Nessuno obbligatorio.

…Path

Regressione: _normalize_paths converte args.path (local_file) in PosixPath;
il placeholder {year} non veniva sostituito su valori Path, quindi i seed
locali con {year} nel path fallivano. Ora sostituito anche su Path.

Test: +2 (path con {year} sostituito, path senza {year} invariato).
CI: mypy falliva — formatted non tipizzato inferiva url come Path,
poi assegnazione str e Path+str. Ora formatted: dict[str, Any] e
base_url = str(formatted['url']) prima del suffix.
@Gabrymi93
Gabrymi93 merged commit 9ae1f90 into main Aug 9, 2026
3 checks passed
@Gabrymi93
Gabrymi93 deleted the fix/raw-format-args-path-year branch August 9, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant