Skip to content

Commit

Permalink
Fix swiss public transport line field none (#133964)
Browse files Browse the repository at this point in the history
* fix #133116

The line can theoretically be none, when no line info is available (lets say walking sections first?)

* fix line field

* add unit test with missing line field
  • Loading branch information
miaucl authored Dec 26, 2024
1 parent b2a160d commit 4023409
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def fetch_connections(self, limit: int) -> list[DataConnection]:
destination=self._opendata.to_name,
remaining_time=str(self.remaining_time(connections[i]["departure"])),
delay=connections[i]["delay"],
line=connections[i]["line"],
line=connections[i].get("line"),
)
for i in range(limit)
if len(connections) > i and connections[i] is not None
Expand All @@ -134,7 +134,7 @@ async def fetch_connections_as_json(self, limit: int) -> list[JsonValueType]:
"train_number": connection["train_number"],
"transfers": connection["transfers"],
"delay": connection["delay"],
"line": connection["line"],
"line": connection.get("line"),
}
for connection in await self.fetch_connections(limit)
]
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"platform": 2,
"transfers": 0,
"duration": "10",
"delay": 0,
"line": "T10"
"delay": 0
},
{
"departure": "2024-01-06T18:06:00+0100",
Expand Down

0 comments on commit 4023409

Please sign in to comment.