Skip to content

Commit 80448bf

Browse files
committed
Add Flake8 corrections for GTFS RT validator
1 parent 352936e commit 80448bf

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

jobs/gtfs-rt-parser-v2/gtfs_rt_parser.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import json
1111
import os
1212
import subprocess
13-
import sys
1413
import tempfile
1514
import traceback
1615
from collections import defaultdict
@@ -19,22 +18,15 @@
1918
from functools import lru_cache
2019
from itertools import islice
2120
from pathlib import Path
22-
from typing import Any, ClassVar, Dict, List, Optional, Sequence, Tuple, Union
21+
from typing import Any, ClassVar, Dict, List, Optional, Tuple
2322

24-
import backoff # type: ignore
2523
import gcsfs # type: ignore
2624
import pendulum
2725
import sentry_sdk
2826
import typer
29-
from aiohttp.client_exceptions import (
30-
ClientOSError,
31-
ClientResponseError,
32-
ServerDisconnectedError,
33-
)
3427
from calitp_data_infra.storage import ( # type: ignore
3528
JSONL_GZIP_EXTENSION,
3629
GTFSDownloadConfig,
37-
GTFSFeedExtract,
3830
GTFSFeedType,
3931
GTFSRTFeedExtract,
4032
GTFSScheduleFeedExtract,
@@ -565,6 +557,7 @@ def process(
565557
exception=e,
566558
process_stderr=stderr,
567559
)
560+
for extract in self.aggregation.extracts
568561
]
569562

570563
if not outcomes:
@@ -581,13 +574,13 @@ def process(
581574
fg=typer.colors.YELLOW,
582575
)
583576

584-
for e in extracts:
577+
for extract in extracts:
585578
outcomes.append(
586579
RTFileProcessingOutcome(
587580
step=self.aggregation.step,
588581
success=False,
589-
extract=e,
590-
aggregation=aggregation,
582+
exception=e,
583+
extract=extract,
591584
)
592585
)
593586
continue
@@ -682,7 +675,7 @@ def process(
682675
feed.ParseFromString(f.read())
683676
parsed = json_format.MessageToDict(feed)
684677
except DecodeError as e:
685-
if verbose:
678+
if self.verbose:
686679
typer.secho(
687680
f"WARNING: DecodeError for {str(extract.path)}",
688681
fg=typer.colors.YELLOW,
@@ -854,10 +847,10 @@ def main(
854847
):
855848
hourly_feed_files = FeedStorage(feed_type).get_hour(hour)
856849
if not hourly_feed_files.valid():
857-
typer.secho(f"missing: {files_missing_metadata}")
858-
typer.secho(f"invalid: {files_invalid_metadata}")
850+
typer.secho(f"missing: {hourly_feed_files.files_missing_metadata}")
851+
typer.secho(f"invalid: {hourly_feed_files.files_invalid_metadata}")
859852
raise RuntimeError(
860-
f"too many files have missing/invalid metadata; {total - len(files)} of {total}" # noqa: E702
853+
f"too many files have missing/invalid metadata; {hourly_feed_files.total - len(hourly_feed_files.files)} of {hourly_feed_files.total}"
861854
)
862855
aggregated_feed = hourly_feed_files.get_query(step, feed_type)
863856
aggregations_to_process = (

0 commit comments

Comments
 (0)