Skip to content

Commit 061bed7

Browse files
committed
Format code with Black
- Reformatted 16 files to comply with Black code style - Fixes CI formatting check failures - No functional changes, only formatting
1 parent 802e8fe commit 061bed7

16 files changed

Lines changed: 44 additions & 27 deletions

tests/conftest.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Pytest configuration and fixtures."""
2+
23
import os
34
import pytest
45
from dotenv import load_dotenv
@@ -22,14 +23,12 @@ def real_client():
2223
"""Provide a client with real credentials from environment."""
2324
client_id = os.getenv("FUEL_FINDER_CLIENT_ID")
2425
client_secret = os.getenv("FUEL_FINDER_CLIENT_SECRET")
25-
26+
2627
if not client_id or not client_secret:
2728
pytest.skip("Real API credentials not available")
28-
29+
2930
return FuelFinderClient(
30-
client_id=client_id,
31-
client_secret=client_secret,
32-
environment="production"
31+
client_id=client_id, client_secret=client_secret, environment="production"
3332
)
3433

3534

tests/integration/test_real_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Integration tests with real API."""
2+
23
import pytest
34
from datetime import datetime, timedelta
45

tests/unit/test_auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Unit tests for authentication module."""
2+
23
import pytest
34
import responses
45
from ukfuelfinder.auth import OAuth2Authenticator

tests/unit/test_cache.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Unit tests for cache module."""
2+
23
import pytest
34
import time
45
from ukfuelfinder.cache import ResponseCache

tests/unit/test_location_search.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Unit tests for location search."""
2+
23
import pytest
34
from ukfuelfinder.client import FuelFinderClient
45
from ukfuelfinder.models import PFSInfo, Location
@@ -13,9 +14,9 @@ def test_haversine_distance(self):
1314
# London to Paris (approx 344 km)
1415
london_lat, london_lon = 51.5074, -0.1278
1516
paris_lat, paris_lon = 48.8566, 2.3522
16-
17+
1718
distance = FuelFinderClient._haversine(london_lon, london_lat, paris_lon, paris_lat)
18-
19+
1920
assert 340 < distance < 350 # Approximate distance
2021

2122
def test_search_by_location(self, monkeypatch):
@@ -59,18 +60,18 @@ def test_search_by_location(self, monkeypatch):
5960
),
6061
),
6162
]
62-
63+
6364
client = FuelFinderClient(client_id="test", client_secret="test")
6465
monkeypatch.setattr(client, "get_all_pfs_info", lambda: mock_sites)
65-
66+
6667
# Search near London
6768
results = client.search_by_location(51.5074, -0.1278, radius_km=5.0)
68-
69+
6970
# Should find first two stations (within 5km), not the third
7071
assert len(results) == 2
7172
assert results[0][1].node_id == "site1" # Closest
7273
assert results[1][1].node_id == "site2"
73-
74+
7475
# Results should be sorted by distance
7576
assert results[0][0] < results[1][0]
7677

@@ -90,13 +91,13 @@ def test_search_by_location_no_results(self, monkeypatch):
9091
),
9192
),
9293
]
93-
94+
9495
client = FuelFinderClient(client_id="test", client_secret="test")
9596
monkeypatch.setattr(client, "get_all_pfs_info", lambda: mock_sites)
96-
97+
9798
# Search far from the station
9899
results = client.search_by_location(51.5074, -0.1278, radius_km=1.0)
99-
100+
100101
assert len(results) == 0
101102

102103
def test_search_by_location_missing_coordinates(self, monkeypatch):
@@ -122,11 +123,11 @@ def test_search_by_location_missing_coordinates(self, monkeypatch):
122123
),
123124
),
124125
]
125-
126+
126127
client = FuelFinderClient(client_id="test", client_secret="test")
127128
monkeypatch.setattr(client, "get_all_pfs_info", lambda: mock_sites)
128-
129+
129130
# Should not crash, just return empty results
130131
results = client.search_by_location(51.5074, -0.1278, radius_km=5.0)
131-
132+
132133
assert len(results) == 0

tests/unit/test_models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Unit tests for models module."""
2+
23
import pytest
34
from datetime import datetime
45
from ukfuelfinder.models import PFS, PFSInfo, FuelPrice, Address, Location
@@ -40,7 +41,7 @@ def test_location_from_dict(self):
4041
"address_line_1": "123 High Street",
4142
"city": "London",
4243
"postcode": "SW1A 1AA",
43-
"country": "England"
44+
"country": "England",
4445
}
4546

4647
location = Location.from_dict(data)
@@ -64,10 +65,10 @@ def test_pfs_info_from_dict(self):
6465
"address_line_1": "123 Street",
6566
"city": "London",
6667
"postcode": "SW1A 1AA",
67-
"country": "England"
68+
"country": "England",
6869
},
6970
"amenities": ["shop", "atm"],
70-
"fuel_types": ["E10", "B7_STANDARD"]
71+
"fuel_types": ["E10", "B7_STANDARD"],
7172
}
7273

7374
pfs_info = PFSInfo.from_dict(data)

tests/unit/test_rate_limiter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Unit tests for rate limiter module."""
2+
23
import pytest
34
import time
45
from ukfuelfinder.rate_limiter import RateLimiter

ukfuelfinder/auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
OAuth 2.0 authentication for UK Fuel Finder API.
33
"""
4+
45
import time
56
import threading
67
from typing import Optional, Dict, Any

ukfuelfinder/cache.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Response caching for UK Fuel Finder API client.
33
"""
4+
45
import time
56
import threading
67
import hashlib

ukfuelfinder/client.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Main client for UK Fuel Finder API.
33
"""
4+
45
from typing import List, Optional, Iterator, Any, Tuple
56
from math import radians, cos, sin, asin, sqrt
67
from .config import Config
@@ -82,7 +83,10 @@ def __init__(
8283

8384
# Price methods
8485
def get_all_pfs_prices(
85-
self, batch_number: Optional[int] = None, effective_start_timestamp: Optional[str] = None, **kwargs: Any
86+
self,
87+
batch_number: Optional[int] = None,
88+
effective_start_timestamp: Optional[str] = None,
89+
**kwargs: Any,
8690
) -> List[PFS]:
8791
"""
8892
Get all PFS fuel prices.
@@ -139,9 +143,7 @@ def get_incremental_price_updates(self, since_timestamp: str, **kwargs: Any) ->
139143
return self.price_service.get_incremental_updates(since_timestamp, **kwargs)
140144

141145
# Forecourt methods
142-
def get_all_pfs_info(
143-
self, batch_number: Optional[int] = None, **kwargs: Any
144-
) -> List[PFSInfo]:
146+
def get_all_pfs_info(self, batch_number: Optional[int] = None, **kwargs: Any) -> List[PFSInfo]:
145147
"""
146148
Get all PFS information.
147149
@@ -165,7 +167,9 @@ def get_incremental_pfs_info(self, since_timestamp: str, **kwargs: Any) -> List[
165167
Returns:
166168
List of updated PFS information
167169
"""
168-
return self.forecourt_service.get_incremental_pfs(effective_start_timestamp=since_timestamp, **kwargs)
170+
return self.forecourt_service.get_incremental_pfs(
171+
effective_start_timestamp=since_timestamp, **kwargs
172+
)
169173

170174
def get_pfs_info(self, node_id: str) -> Optional[PFSInfo]:
171175
"""

0 commit comments

Comments
 (0)