Skip to content

Commit 214a47e

Browse files
committed
=Fix ruff
1 parent e722c9d commit 214a47e

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ ignore = [
141141
"D213", # Conflicts with other rules
142142
"D417", # False positives in some occasions
143143
"PLR2004", # Just annoying, not really useful
144+
"TCH001",
144145
]
145146
select = ["ALL"]
146147

src/opensky/models.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"""Asynchronous Python client for the OpenSky API."""
22
from __future__ import annotations
33

4-
from dataclasses import dataclass
5-
from datetime import date, datetime, timezone
6-
7-
from pydantic import BaseModel, Field, validator
4+
from pydantic import BaseModel, Field
85

96
from .const import AircraftCategory, PositionSource
107

@@ -18,12 +15,14 @@ class StatesResponse(BaseModel):
1815

1916
class StateVector(BaseModel):
2017
"""Represents the state of a vehicle at a particular time.
18+
2119
Attributes
2220
----------
2321
icao24: ICAO24 address of the transmitter in hex string representation.
2422
callsign: Callsign of the vehicle.
2523
origin_country: Inferred through the ICAO24 address.
26-
time_position: Seconds since epoch of last position report. Can be None if there was no position report received by OpenSky within 15s before.
24+
time_position: Seconds since epoch of last position report. Can be None if there
25+
was no position report received by OpenSky within 15s before.
2726
last_contact: Seconds since epoch of last received message from this transponder.
2827
longitude: In ellipsoidal coordinates (WGS-84) and degrees.
2928
latitude: In ellipsoidal coordinates (WGS-84) and degrees.
@@ -32,7 +31,8 @@ class StateVector(BaseModel):
3231
velocity: Over ground in m/s.
3332
true_track: In decimal degrees (0 is north).
3433
vertical_rate: In m/s, incline is positive, decline negative.
35-
sensors: Serial numbers of sensors which received messages from the vehicle within the validity period of this state vector.
34+
sensors: Serial numbers of sensors which received messages from the vehicle within
35+
the validity period of this state vector.
3636
barometric_altitude: Barometric altitude in meters.
3737
transponder_code: Transponder code aka Squawk.
3838
special_purpose_indicator: Special purpose indicator.

src/opensky/opensky.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,26 @@ async def _request(
3232
*,
3333
data: dict[str, Any] | None = None,
3434
) -> dict[str, Any]:
35-
"""Handle a request to a RDW open data (Socrata).
35+
"""Handle a request to OpenSky.
36+
3637
A generic method for sending/handling HTTP requests done against
37-
the public RDW data.
38+
OpenSky.
39+
3840
Args:
3941
----
40-
dataset: Identifier for the Socrata dataset to query.
41-
data: Dictionary of data to send to the Socrata API.
42+
uri: the path to call.
43+
data: the query parameters to add.
44+
4245
Returns:
4346
-------
4447
A Python dictionary (JSON decoded) with the response from
4548
the API.
49+
4650
Raises:
4751
------
48-
RDWConnectionError: An error occurred while communicating with
49-
the Socrata API.
50-
RDWError: Received an unexpected response from the Socrata API.
52+
OpenSkyConnectionError: An error occurred while communicating with
53+
the OpenSky API.
54+
OpenSkyrror: Received an unexpected response from the OpenSky API.
5155
"""
5256
version = metadata.version(__package__)
5357
url = URL.build(
@@ -140,7 +144,7 @@ async def states(self) -> StatesResponse:
140144
"category",
141145
]
142146

143-
data = {**data, "states": [dict(zip(keys, state)) for state in data["states"]]}
147+
data = {**data, "states": [dict(zip(keys, state, strict=True)) for state in data["states"]]}
144148

145149
return StatesResponse.parse_obj(data)
146150

@@ -151,6 +155,7 @@ async def close(self) -> None:
151155

152156
async def __aenter__(self) -> OpenSky:
153157
"""Async enter.
158+
154159
Returns
155160
-------
156161
The OpenSky object.
@@ -159,6 +164,7 @@ async def __aenter__(self) -> OpenSky:
159164

160165
async def __aexit__(self, *_exc_info: Any) -> None:
161166
"""Async exit.
167+
162168
Args:
163169
----
164170
_exc_info: Exec type.

0 commit comments

Comments
 (0)