feat: Python SDK update for version 19.0.0#143
Conversation
Greptile SummaryThis PR updates the Python SDK to version 19.0.0, introducing three new services (
Confidence Score: 4/5The core SDK logic is sound, but three presence service tests (test_get, test_upsert, test_update_presence) will fail in CI because their fixture dicts do not include the 'metadata': {} key that Presence.to_dict() unconditionally injects. All new service logic (Advisor, Usage, Presences) is correctly implemented and the pre-existing with_data bug was fixed. However, the three new presence test assertions compare against fixtures that lack 'metadata': {}, which Presence.to_dict() always appends — the same way database tests explicitly add data['data'] = {} before asserting. Those tests will not pass as written. The open item about OAuth2GooglePrompt / ProjectOAuth2GooglePrompt duplication is a design concern but does not affect runtime behavior. test/services/test_presences.py — the three single-presence test assertions need data['metadata'] = {} added before the assertEqual call, mirroring the pattern used in test_databases.py. Important Files Changed
Reviews (3): Last reviewed commit: "chore: update Python SDK to 19.0.0" | Re-trigger Greptile |
| from enum import Enum | ||
|
|
||
| class OAuth2GooglePrompt(Enum): | ||
| NONE = "none" | ||
| CONSENT = "consent" | ||
| SELECT_ACCOUNT = "select_account" |
There was a problem hiding this comment.
Duplicate enum with
ProjectOAuth2GooglePrompt
OAuth2GooglePrompt (this file) and ProjectOAuth2GooglePrompt (appwrite/enums/project_o_auth2_google_prompt.py) define the exact same three values (none, consent, select_account). Both are imported and registered in value_class_encoder.py. The encoder handles OAuth2GooglePrompt but no service or model appears to accept it as a parameter — only ProjectOAuth2GooglePrompt is used in project.py. If OAuth2GooglePrompt is a legacy shim it should be marked deprecated; if it is truly redundant it should be removed.
| def to_dict(self) -> Dict[str, Any]: | ||
| result = super().to_dict() | ||
| if hasattr(self, '_metadata'): | ||
| if isinstance(self._metadata, dict): | ||
| result['metadata'] = self._metadata | ||
| elif hasattr(self._metadata, 'model_dump'): | ||
| result['metadata'] = self._metadata.model_dump(mode='json') | ||
| else: | ||
| result['metadata'] = self._metadata | ||
| return result |
There was a problem hiding this comment.
to_dict() always injects metadata: {} into the output
_metadata is initialized via PrivateAttr(default_factory=dict), so hasattr(self, '_metadata') is always True and isinstance({}, dict) is always True. Every call to to_dict() will therefore add "metadata": {} to the result — even when no user-defined metadata was ever set. The three test assertions in test_presences.py (test_get, test_upsert, test_update_presence) all compare response.to_dict() against fixtures that have no "metadata" key, so all three tests will fail at runtime.
| def to_dict(self) -> Dict[str, Any]: | |
| result = super().to_dict() | |
| if hasattr(self, '_metadata'): | |
| if isinstance(self._metadata, dict): | |
| result['metadata'] = self._metadata | |
| elif hasattr(self._metadata, 'model_dump'): | |
| result['metadata'] = self._metadata.model_dump(mode='json') | |
| else: | |
| result['metadata'] = self._metadata | |
| return result | |
| def to_dict(self) -> Dict[str, Any]: | |
| result = super().to_dict() | |
| if hasattr(self, '_metadata') and self._metadata: | |
| if isinstance(self._metadata, dict): | |
| result['metadata'] = self._metadata | |
| elif hasattr(self._metadata, 'model_dump'): | |
| result['metadata'] = self._metadata.model_dump(mode='json') | |
| else: | |
| result['metadata'] = self._metadata | |
| return result |
This PR contains updates to the Python SDK for version 19.0.0.
What's Changed
AuthMethodenum toProjectAuthMethodIdEmailTemplateTypetoProjectEmailTemplateIdandEmailTemplateLocaletoProjectEmailTemplateLocaleServiceIdtoProjectServiceId,ProtocolIdtoProjectProtocolId,SecuretoProjectSMTPSecure,ProjectPolicytoProjectPolicyIdScopesenum withProjectKeyScopesfor project key endpointsupdate_deny_canonical_email_policy; replaced withupdate_deny_aliased_email_policy,update_deny_disposable_email_policy, andupdate_deny_free_email_policyAuthProvidermodel; use newProjectOAuthProviderIdenum insteadProject.getmethod to fetch current project detailsAdvisor,Presences, andUsageservicesInsight,Presence,Report,UsageEvent, andUsageGaugemodels with list variantsProjectAuthMethod,ProjectProtocol, andProjectServicemodelsProjectOAuthProviderIdandProjectOAuth2GooglePromptenumsProject,Database, andOAuth2Googlemodel schemasX-Appwrite-Response-Formatheader to1.9.5