Skip to content

fix(typing): align _ClientMixin protocols with ClassVar client attributes - #441

Open
eldertek wants to merge 1 commit into
getlago:mainfrom
eldertek:fix/330-client-mixin-typing
Open

eldertek wants to merge 1 commit into
getlago:mainfrom
eldertek:fix/330-client-mixin-typing

Conversation

@eldertek

Copy link
Copy Markdown

Context

Fixes #330.

Static type checkers such as Pyright flag errors on client classes inheriting from BaseClient and _ClientMixin (CreateCommandMixin, FindCommandMixin, _ChildClientMixin, etc.) because BaseClient stacked @property, @classmethod, and @abstractmethod on API_RESOURCE, RESPONSE_MODEL, and ROOT_NAME, while _ClientMixin declared abstract instance properties incompatible with ClassVar overrides and non-optional options/params query parameters.

Description

  • Declare API_RESOURCE, RESPONSE_MODEL, and ROOT_NAME as ClassVar attributes on BaseClient (lago_python_client/base_client.py).
  • Align _ClientMixin with ClassVar attributes, split _ChildClientMixin (PARENT_API_RESOURCE) from _NestedClientMixin (api_resource), and type options/params as Optional[QueryPairs] in lago_python_client/mixins.py and make_url (lago_python_client/services/request.py).
  • Add regression tests in tests/test_mixin_protocols.py covering static and runtime mixin contracts (522 passed in pytest, ruff clean).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: _ClientMixin is not typed properly

1 participant