Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions mpt_api_client/resources/accounts/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class AccountsServiceConfig:


class AccountsService(
CreateFileMixin[Model],
UpdateFileMixin[Model],
ActivatableMixin[Model],
EnablableMixin[Model],
ValidateMixin[Model],
CreateFileMixin[Account],
UpdateFileMixin[Account],
ActivatableMixin[Account],
EnablableMixin[Account],
ValidateMixin[Account],
GetMixin[Account],
CollectionMixin[Account],
Service[Account],
Expand All @@ -59,11 +59,11 @@ def users(self, account_id: str) -> AccountsUsersService:


class AsyncAccountsService(
AsyncCreateFileMixin[Model],
AsyncUpdateFileMixin[Model],
AsyncActivatableMixin[Model],
AsyncEnablableMixin[Model],
AsyncValidateMixin[Model],
AsyncCreateFileMixin[Account],
AsyncUpdateFileMixin[Account],
AsyncActivatableMixin[Account],
AsyncEnablableMixin[Account],
AsyncValidateMixin[Account],
AsyncGetMixin[Account],
AsyncCollectionMixin[Account],
AsyncService[Account],
Expand Down
20 changes: 10 additions & 10 deletions mpt_api_client/resources/accounts/buyers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class BuyersServiceConfig:


class BuyersService(
CreateFileMixin[Model],
UpdateFileMixin[Model],
ActivatableMixin[Model],
EnablableMixin[Model],
ValidateMixin[Model],
CreateFileMixin[Buyer],
UpdateFileMixin[Buyer],
ActivatableMixin[Buyer],
EnablableMixin[Buyer],
ValidateMixin[Buyer],
GetMixin[Buyer],
DeleteMixin,
CollectionMixin[Buyer],
Expand Down Expand Up @@ -71,11 +71,11 @@ def transfer(self, resource_id: str, resource_data: ResourceData | None = None)


class AsyncBuyersService(
AsyncCreateFileMixin[Model],
AsyncUpdateFileMixin[Model],
AsyncActivatableMixin[Model],
AsyncEnablableMixin[Model],
AsyncValidateMixin[Model],
AsyncCreateFileMixin[Buyer],
AsyncUpdateFileMixin[Buyer],
AsyncActivatableMixin[Buyer],
AsyncEnablableMixin[Buyer],
AsyncValidateMixin[Buyer],
AsyncGetMixin[Buyer],
AsyncDeleteMixin,
AsyncCollectionMixin[Buyer],
Expand Down
12 changes: 6 additions & 6 deletions mpt_api_client/resources/accounts/licensees.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class LicenseesServiceConfig:


class LicenseesService(
CreateFileMixin[Model],
UpdateFileMixin[Model],
EnablableMixin[Model],
CreateFileMixin[Licensee],
UpdateFileMixin[Licensee],
EnablableMixin[Licensee],
GetMixin[Licensee],
DeleteMixin,
CollectionMixin[Licensee],
Expand All @@ -46,9 +46,9 @@ class LicenseesService(


class AsyncLicenseesService(
AsyncCreateFileMixin[Model],
AsyncUpdateFileMixin[Model],
AsyncEnablableMixin[Model],
AsyncCreateFileMixin[Licensee],
AsyncUpdateFileMixin[Licensee],
AsyncEnablableMixin[Licensee],
AsyncGetMixin[Licensee],
AsyncDeleteMixin,
AsyncCollectionMixin[Licensee],
Expand Down
2 changes: 1 addition & 1 deletion mpt_api_client/resources/accounts/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ class ModulesService(


class AsyncModulesService(
AsyncGetMixin[Module], AsyncCollectionMixin[Model], AsyncService[Module], ModulesServiceConfig
AsyncGetMixin[Module], AsyncCollectionMixin[Module], AsyncService[Module], ModulesServiceConfig
):
"""Asynchronous Modules Service."""
2 changes: 1 addition & 1 deletion seed/accounts/buyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def init_buyer(
context["accounts.buyer.id"] = created.id
logger.info("Buyer created: %s", created.id)
return created
logger.warning("Buyer creation failed")
logger.warning("Buyer creation failed") # type: ignore[unreachable]
raise ValueError("Buyer creation failed")
logger.info("Buyer found: %s", buyer.id)
return buyer
Expand Down
2 changes: 1 addition & 1 deletion seed/accounts/licensee.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def init_licensee(
context["accounts.licensee.id"] = created.id
logger.info("Licensee created: %s", created.id)
return created
logger.warning("Licensee creation failed")
logger.warning("Licensee creation failed") # type: ignore[unreachable]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise ValueError("Licensee creation failed")
logger.info("Licensee found: %s", licensee.id)
return licensee
Expand Down
2 changes: 1 addition & 1 deletion seed/accounts/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def refresh_module(
context["accounts.module.id"] = first_module.id
context.set_resource("accounts.module", first_module)
return first_module
logger.warning("First module is not a Module instance.")
logger.warning("First module is not a Module instance.") # type: ignore[unreachable]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful with this kind of errors, we shouldn't ignore it since it mens the code after this point will never run. Did you check that the typing is correct? did you try using cast method?

I'd be great to improve a bit this logic using guard clauses or early returns, that way we avoid the spaguetti code and it's simpler to read and understand

Something like ->

    """Refresh module in context (always fetch)."""
    module = await get_module(context=context, mpt_operations=mpt_operations)
    if module:
        return module

    filtered_modules = mpt_operations.accounts.modules.filter(
        RQLQuery(name="Access Management")
    )
    modules = [mod async for mod in filtered_modules.iterate()]
    if not modules:
        logger.warning("Module 'Access Management' not found.")
        return None

    first_module = modules[0]
    if not isinstance(first_module, Module):
        logger.warning("First module is not a Module instance.")  # type: ignore[unreachable]
        return None
    
    context["accounts.module.id"] = first_module.id
    context.set_resource("accounts.module", first_module)
    return first_module

return None
logger.warning("Module 'Access Management' not found.")
return None
Expand Down