Skip to content

Commit ee74fde

Browse files
authored
MPT-16304 Ensure correct model is used in services (#157)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Enhanced type consistency across account and module service classes for improved type safety and better IDE support. * Aligned generic type parameters in service mixins to accurately match their specific resource types. * **Chores** * Added type annotations to improve static code analysis in seed utilities. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents d927ac4 + 5f5a229 commit ee74fde

7 files changed

Lines changed: 30 additions & 30 deletions

File tree

mpt_api_client/resources/accounts/account.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ class AccountsServiceConfig:
3939

4040

4141
class AccountsService(
42-
CreateFileMixin[Model],
43-
UpdateFileMixin[Model],
44-
ActivatableMixin[Model],
45-
EnablableMixin[Model],
46-
ValidateMixin[Model],
42+
CreateFileMixin[Account],
43+
UpdateFileMixin[Account],
44+
ActivatableMixin[Account],
45+
EnablableMixin[Account],
46+
ValidateMixin[Account],
4747
GetMixin[Account],
4848
CollectionMixin[Account],
4949
Service[Account],
@@ -59,11 +59,11 @@ def users(self, account_id: str) -> AccountsUsersService:
5959

6060

6161
class AsyncAccountsService(
62-
AsyncCreateFileMixin[Model],
63-
AsyncUpdateFileMixin[Model],
64-
AsyncActivatableMixin[Model],
65-
AsyncEnablableMixin[Model],
66-
AsyncValidateMixin[Model],
62+
AsyncCreateFileMixin[Account],
63+
AsyncUpdateFileMixin[Account],
64+
AsyncActivatableMixin[Account],
65+
AsyncEnablableMixin[Account],
66+
AsyncValidateMixin[Account],
6767
AsyncGetMixin[Account],
6868
AsyncCollectionMixin[Account],
6969
AsyncService[Account],

mpt_api_client/resources/accounts/buyers.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class BuyersServiceConfig:
3838

3939

4040
class BuyersService(
41-
CreateFileMixin[Model],
42-
UpdateFileMixin[Model],
43-
ActivatableMixin[Model],
44-
EnablableMixin[Model],
45-
ValidateMixin[Model],
41+
CreateFileMixin[Buyer],
42+
UpdateFileMixin[Buyer],
43+
ActivatableMixin[Buyer],
44+
EnablableMixin[Buyer],
45+
ValidateMixin[Buyer],
4646
GetMixin[Buyer],
4747
DeleteMixin,
4848
CollectionMixin[Buyer],
@@ -71,11 +71,11 @@ def transfer(self, resource_id: str, resource_data: ResourceData | None = None)
7171

7272

7373
class AsyncBuyersService(
74-
AsyncCreateFileMixin[Model],
75-
AsyncUpdateFileMixin[Model],
76-
AsyncActivatableMixin[Model],
77-
AsyncEnablableMixin[Model],
78-
AsyncValidateMixin[Model],
74+
AsyncCreateFileMixin[Buyer],
75+
AsyncUpdateFileMixin[Buyer],
76+
AsyncActivatableMixin[Buyer],
77+
AsyncEnablableMixin[Buyer],
78+
AsyncValidateMixin[Buyer],
7979
AsyncGetMixin[Buyer],
8080
AsyncDeleteMixin,
8181
AsyncCollectionMixin[Buyer],

mpt_api_client/resources/accounts/licensees.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class LicenseesServiceConfig:
3333

3434

3535
class LicenseesService(
36-
CreateFileMixin[Model],
37-
UpdateFileMixin[Model],
38-
EnablableMixin[Model],
36+
CreateFileMixin[Licensee],
37+
UpdateFileMixin[Licensee],
38+
EnablableMixin[Licensee],
3939
GetMixin[Licensee],
4040
DeleteMixin,
4141
CollectionMixin[Licensee],
@@ -46,9 +46,9 @@ class LicenseesService(
4646

4747

4848
class AsyncLicenseesService(
49-
AsyncCreateFileMixin[Model],
50-
AsyncUpdateFileMixin[Model],
51-
AsyncEnablableMixin[Model],
49+
AsyncCreateFileMixin[Licensee],
50+
AsyncUpdateFileMixin[Licensee],
51+
AsyncEnablableMixin[Licensee],
5252
AsyncGetMixin[Licensee],
5353
AsyncDeleteMixin,
5454
AsyncCollectionMixin[Licensee],

mpt_api_client/resources/accounts/modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ class ModulesService(
2727

2828

2929
class AsyncModulesService(
30-
AsyncGetMixin[Module], AsyncCollectionMixin[Model], AsyncService[Module], ModulesServiceConfig
30+
AsyncGetMixin[Module], AsyncCollectionMixin[Module], AsyncService[Module], ModulesServiceConfig
3131
):
3232
"""Asynchronous Modules Service."""

seed/accounts/buyer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def init_buyer(
7878
context["accounts.buyer.id"] = created.id
7979
logger.info("Buyer created: %s", created.id)
8080
return created
81-
logger.warning("Buyer creation failed")
81+
logger.warning("Buyer creation failed") # type: ignore[unreachable]
8282
raise ValueError("Buyer creation failed")
8383
logger.info("Buyer found: %s", buyer.id)
8484
return buyer

seed/accounts/licensee.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def init_licensee(
8989
context["accounts.licensee.id"] = created.id
9090
logger.info("Licensee created: %s", created.id)
9191
return created
92-
logger.warning("Licensee creation failed")
92+
logger.warning("Licensee creation failed") # type: ignore[unreachable]
9393
raise ValueError("Licensee creation failed")
9494
logger.info("Licensee found: %s", licensee.id)
9595
return licensee

seed/accounts/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def refresh_module(
5050
context["accounts.module.id"] = first_module.id
5151
context.set_resource("accounts.module", first_module)
5252
return first_module
53-
logger.warning("First module is not a Module instance.")
53+
logger.warning("First module is not a Module instance.") # type: ignore[unreachable]
5454
return None
5555
logger.warning("Module 'Access Management' not found.")
5656
return None

0 commit comments

Comments
 (0)