Skip to content

Commit 6a42c34

Browse files
committed
Adopt attrs converters, rename ServerConfig.type to api_type, fix Location defaults
- Replace manual __init__ methods with attrs converters/factories across all model classes, using _flexible_init decorator to handle unknown API keys. - Rename ServerConfig.type to api_type to avoid shadowing the builtin. Update all references in client.py, auth/factory.py, and tests. - Fix Location.__init__ bug where field() objects were used as parameter defaults instead of None (now fixed by removing manual __init__).
1 parent 917bfef commit 6a42c34

5 files changed

Lines changed: 340 additions & 692 deletions

File tree

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:

0 commit comments

Comments
 (0)