Skip to content

Commit

Permalink
Change to list comprehension
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasnicolaas committed Jul 4, 2023
1 parent ea56fa0 commit 97e82cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 4 additions & 8 deletions examples/disabled_parking.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@ async def main() -> None:
async with ODPAntwerpen() as client:
disabled_parkings = await client.disabled_parkings(limit=100)

count: int
for index, item in enumerate(disabled_parkings, 1):
count = index
count = len(disabled_parkings)
for item in disabled_parkings:
print(item)

# Count unique id's in disabled_parkings
unique_values: list[int] = []
for item in disabled_parkings:
unique_values.append(item.entry_id)
num_values = len(set(unique_values))
unique_values = len({item.entry_id for item in disabled_parkings})

print("__________________________")
print(f"Total locations found: {count}")
print(f"Unique ID values: {num_values}")
print(f"Unique ID values: {unique_values}")


if __name__ == "__main__":
Expand Down
6 changes: 1 addition & 5 deletions src/antwerpen/antwerpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ async def disabled_parkings(self, limit: int = 10) -> list[DisabledParking]:
-------
A list of DisabledParking objects.
"""
results: list[DisabledParking] = []
locations = await self._request(
"portal_publiek6/MapServer/585/query",
params={
Expand All @@ -116,10 +115,7 @@ async def disabled_parkings(self, limit: int = 10) -> list[DisabledParking]:
"f": "geojson",
},
)

for item in locations["features"]:
results.append(DisabledParking.from_dict(item))
return results
return [DisabledParking.from_dict(item) for item in locations["features"]]

async def close(self) -> None:
"""Close open client session."""
Expand Down

0 comments on commit 97e82cd

Please sign in to comment.