Skip to content

Commit 8a078e5

Browse files
committed
chore: run formatter and fix flake8
1 parent eeb1809 commit 8a078e5

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from __future__ import annotations
2+
3+
"""A class representing the SubscriptionPriceConnection type from the GraphQL Tibber API."""
4+
from typing import TYPE_CHECKING
5+
6+
from tibber.types.price import Price
7+
from tibber.types.subscription_price_connection_page_info import \
8+
SubscriptionPriceConnectionPageInfo
9+
from tibber.types.subscription_price_edge import SubscriptionPriceEdge
10+
11+
if TYPE_CHECKING:
12+
from tibber.account import Account
13+
14+
15+
class SubscriptionPriceConnection:
16+
"""A class to get subscription price connection."""
17+
18+
def __init__(self, data: dict, tibber_client: "Account"):
19+
self.cache: dict = data or {}
20+
self.tibber_client: "Account" = tibber_client
21+
22+
@property
23+
def edges(self) -> list[SubscriptionPriceEdge]:
24+
return [
25+
SubscriptionPriceEdge(edge, self.tibber_client)
26+
for edge in self.cache.get("edges", [])
27+
]
28+
29+
@property
30+
def pageInfo(self) -> SubscriptionPriceConnectionPageInfo:
31+
return SubscriptionPriceConnectionPageInfo(
32+
self.cache.get("pageInfo"), self.tibber_client
33+
)
34+
35+
@property
36+
def nodes(self) -> list[Price]:
37+
"""List of Price objects from the executed range query."""
38+
return [Price(node, self.tibber_client) for node in self.cache.get("nodes", [])]

tibber/types/subscription_price_connection_page_info.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"""A class representing the SubscriptionPriceConnectionPageInfo type from the GraphQL Tibber API."""
44
from typing import TYPE_CHECKING
55

6+
if TYPE_CHECKING:
7+
from tibber.account import Account
8+
69

710
class SubscriptionPriceConnectionPageInfo:
811
def __init__(self, data: dict, tibber_client: "Account"):

tibber/types/subscription_price_edge.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
from tibber.types.price import Price
77

8+
if TYPE_CHECKING:
9+
from tibber.account import Account
10+
811

912
class SubscriptionPriceEdge:
1013
def __init__(self, data: dict, tibber_client: "Account"):

0 commit comments

Comments
 (0)