Skip to content

Commit 3b6d6ce

Browse files
authored
Rename ServerConfig.type to api_type (#1995)
## Summary - Rename `ServerConfig.type` to `ServerConfig.api_type` to avoid shadowing the Python builtin `type` - Update all references in `client.py`, `auth/factory.py`, and tests ## Test plan - [x] All 280 tests pass - [x] ruff, mypy, ty all pass
1 parent 917bfef commit 3b6d6ce

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

pyoverkiz/auth/factory.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def build_auth_strategy(
4343
session,
4444
server_config,
4545
ssl_context,
46-
server_config.type,
46+
server_config.api_type,
4747
)
4848

4949
if server in {
@@ -56,7 +56,7 @@ def build_auth_strategy(
5656
session,
5757
server_config,
5858
ssl_context,
59-
server_config.type,
59+
server_config.api_type,
6060
)
6161

6262
if server == Server.NEXITY:
@@ -65,7 +65,7 @@ def build_auth_strategy(
6565
session,
6666
server_config,
6767
ssl_context,
68-
server_config.type,
68+
server_config.api_type,
6969
)
7070

7171
if server == Server.REXEL:
@@ -74,35 +74,35 @@ def build_auth_strategy(
7474
session,
7575
server_config,
7676
ssl_context,
77-
server_config.type,
77+
server_config.api_type,
7878
)
7979

80-
if server_config.type == APIType.LOCAL:
80+
if server_config.api_type == APIType.LOCAL:
8181
if isinstance(credentials, LocalTokenCredentials):
8282
return LocalTokenAuthStrategy(
83-
credentials, session, server_config, ssl_context, server_config.type
83+
credentials, session, server_config, ssl_context, server_config.api_type
8484
)
8585
return BearerTokenAuthStrategy(
8686
_ensure_token(credentials),
8787
session,
8888
server_config,
8989
ssl_context,
90-
server_config.type,
90+
server_config.api_type,
9191
)
9292

9393
if isinstance(credentials, TokenCredentials) and not isinstance(
9494
credentials, LocalTokenCredentials
9595
):
9696
return BearerTokenAuthStrategy(
97-
credentials, session, server_config, ssl_context, server_config.type
97+
credentials, session, server_config, ssl_context, server_config.api_type
9898
)
9999

100100
return SessionLoginStrategy(
101101
_ensure_username_password(credentials),
102102
session,
103103
server_config,
104104
ssl_context,
105-
server_config.type,
105+
server_config.api_type,
106106
)
107107

108108

pyoverkiz/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def __init__(
187187
)
188188
self._ssl = verify_ssl
189189

190-
if self.server_config.type == APIType.LOCAL and verify_ssl:
190+
if self.server_config.api_type == APIType.LOCAL and verify_ssl:
191191
# Use the prebuilt SSL context with disabled strict validation for local API.
192192
self._ssl = SSL_CONTEXT_LOCAL_API
193193

@@ -268,7 +268,7 @@ async def login(
268268
"""
269269
await self._auth.login()
270270

271-
if self.server_config.type == APIType.LOCAL:
271+
if self.server_config.api_type == APIType.LOCAL:
272272
if register_event_listener:
273273
await self.register_event_listener()
274274
else:

pyoverkiz/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ class ServerConfig:
11801180
name: str
11811181
endpoint: str
11821182
manufacturer: str
1183-
type: APIType
1183+
api_type: APIType
11841184
configuration_url: str | None = None
11851185

11861186
def __init__(
@@ -1201,7 +1201,7 @@ def __init__(
12011201
self.name = name
12021202
self.endpoint = endpoint
12031203
self.manufacturer = manufacturer
1204-
self.type = api_type if isinstance(api_type, APIType) else APIType(api_type)
1204+
self.api_type = api_type if isinstance(api_type, APIType) else APIType(api_type)
12051205
self.configuration_url = configuration_url
12061206

12071207

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ async def local_client(self):
5050
@pytest.mark.asyncio
5151
async def test_get_api_type_cloud(self, client: OverkizClient):
5252
"""Verify that a cloud-configured client reports APIType.CLOUD."""
53-
assert client.server_config.type == APIType.CLOUD
53+
assert client.server_config.api_type == APIType.CLOUD
5454

5555
@pytest.mark.asyncio
5656
async def test_get_api_type_local(self, local_client: OverkizClient):
5757
"""Verify that a local-configured client reports APIType.LOCAL."""
58-
assert local_client.server_config.type == APIType.LOCAL
58+
assert local_client.server_config.api_type == APIType.LOCAL
5959

6060
@pytest.mark.asyncio
6161
async def test_get_devices_basic(self, client: OverkizClient):

0 commit comments

Comments
 (0)