Skip to content

Commit 06405ec

Browse files
committed
Use region type
1 parent 535ad15 commit 06405ec

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tesla_fleet_api/tesla/oauth.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import time
2-
from typing import Any, Literal
2+
from typing import Any
33

44
import aiohttp
55

6-
from tesla_fleet_api.const import SERVERS, Method, Scope
6+
from tesla_fleet_api.const import SERVERS, Method, Region, Scope, is_valid_region
77
from tesla_fleet_api.tesla import TeslaFleetApi
88

99

@@ -19,14 +19,17 @@ class TeslaFleetOAuth(TeslaFleetApi):
1919
def __init__(
2020
self,
2121
session: aiohttp.ClientSession,
22-
region: Literal["na", "eu", "cn"],
22+
region: Region,
2323
client_id: str,
2424
client_secret: str | None = None,
2525
redirect_uri: str | None = None,
2626
access_token: str | None = None,
2727
refresh_token: str | None = None,
2828
expires: int = 0,
2929
):
30+
if not is_valid_region(region):
31+
raise ValueError("Invalid region")
32+
3033
self.client_id = client_id
3134
self._client_secret = client_secret
3235
self.redirect_uri = redirect_uri

0 commit comments

Comments
 (0)