Skip to content

Commit

Permalink
drop 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanbconaway committed Nov 9, 2024
1 parent 4496a26 commit bccb61d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
author_email="nolanbconaway@gmail.com",
url="https://github.com/nolanbconaway/underground",
classifiers=[
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
7 changes: 3 additions & 4 deletions src/underground/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import time
import typing

import google
import protobuf_to_dict
Expand Down Expand Up @@ -38,7 +37,7 @@ def load_protobuf(protobuf_bytes: bytes) -> dict:
return feed_dict


def request(route_or_url: str, api_key: typing.Optional[str] = None) -> bytes:
def request(route_or_url: str, api_key: str | None = None) -> bytes:
"""Send a HTTP GET request to the MTA for realtime feed data.
Occassionally a feed is requested as the MTA is writing updated data to the file,
Expand Down Expand Up @@ -80,9 +79,9 @@ def request(route_or_url: str, api_key: typing.Optional[str] = None) -> bytes:
def request_robust(
route_or_url: str,
retries: int = 100,
api_key: typing.Optional[str] = None,
api_key: str | None = None,
return_dict: bool = False,
) -> typing.Union[dict, bytes]:
) -> dict | bytes:
"""Request feed data with validations and retries.
Occassionally a feed is requested as the MTA is writing updated data to the file,
Expand Down
33 changes: 15 additions & 18 deletions src/underground/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Pydantic data models for MTA GFTS data."""

import datetime
import typing

import pydantic
import pytz
Expand All @@ -12,10 +11,10 @@
class UnixTimestamp(pydantic.BaseModel):
"""A unix timestamp model."""

time: typing.Optional[datetime.datetime] = None
time: datetime.datetime | None = None

@property
def timestamp_nyc(self) -> typing.Optional[datetime.datetime]:
def timestamp_nyc(self) -> datetime.datetime | None:
"""Return the NYC datetime."""
if not self.time:
return None
Expand All @@ -38,7 +37,7 @@ class Trip(pydantic.BaseModel):
"""Model describing a train trip."""

trip_id: str
start_time: typing.Optional[datetime.time] = None
start_time: datetime.time | None = None
start_date: int
route_id: str

Expand Down Expand Up @@ -92,11 +91,11 @@ class StopTimeUpdate(pydantic.BaseModel):
"""

stop_id: str
arrival: typing.Optional[UnixTimestamp] = None
departure: typing.Optional[UnixTimestamp] = None
arrival: UnixTimestamp | None = None
departure: UnixTimestamp | None = None

@property
def depart_or_arrive(self) -> typing.Optional[UnixTimestamp]:
def depart_or_arrive(self) -> UnixTimestamp | None:
"""Return the departure or arrival time if either are specified.
This OR should usually be called because the MTA is inconsistent about when
Expand All @@ -122,7 +121,7 @@ class TripUpdate(pydantic.BaseModel):
"""

trip: Trip
stop_time_update: typing.Optional[typing.List[StopTimeUpdate]] = None
stop_time_update: list[StopTimeUpdate] | None = None


class Vehicle(pydantic.BaseModel):
Expand Down Expand Up @@ -152,9 +151,9 @@ class Vehicle(pydantic.BaseModel):
"""

trip: Trip
timestamp: typing.Optional[datetime.datetime] = None
current_stop_sequence: typing.Optional[int] = None
stop_id: typing.Optional[str] = None
timestamp: datetime.datetime | None = None
current_stop_sequence: int | None = None
stop_id: str | None = None


class Entity(pydantic.BaseModel):
Expand All @@ -165,8 +164,8 @@ class Entity(pydantic.BaseModel):
"""

id: str
vehicle: typing.Optional[Vehicle] = None
trip_update: typing.Optional[TripUpdate] = None
vehicle: Vehicle | None = None
trip_update: TripUpdate | None = None


class SubwayFeed(pydantic.BaseModel):
Expand All @@ -176,12 +175,10 @@ class SubwayFeed(pydantic.BaseModel):
"""

header: FeedHeader
entity: typing.List[Entity]
entity: list[Entity]

@staticmethod
def get(
route_or_url: str, retries: int = 100, api_key: typing.Optional[str] = None
) -> "SubwayFeed":
def get(route_or_url: str, retries: int = 100, api_key: str | None = None) -> "SubwayFeed":
"""Request feed data from the MTA.
Parameters
Expand Down Expand Up @@ -214,7 +211,7 @@ def get(

def extract_stop_dict(
self, timezone: str = metadata.DEFAULT_TIMEZONE, stalled_timeout: int = 90
) -> typing.Dict[str, typing.Dict[str, typing.List[datetime.datetime]]]:
) -> dict[str, dict[str, list[datetime.datetime]]]:
"""Get the departure times for all stops in the feed.
Parameters
Expand Down

0 comments on commit bccb61d

Please sign in to comment.