Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: Add typed stub for twilio.rest.Client + to_dict type hints fix#899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
al-chris wants to merge3 commits intotwilio:main
base:main
Choose a base branch
Loading
fromal-chris:main

Conversation

@al-chris
Copy link

Fixes

Summary

  • Added a type stub exposing theClient initializer and domain properties:twilio/rest/__init__.pyi.
  • Included a follow-up runtime fix that adds return type hints toto_dict() methods and safer policy handling in the Knowledge module.

Commits included

  • 914845712 feat: add initial typings for Twilio REST client
  • e70d11fac fix: add type hints and improve policy handling in to_dict methods

Files changed

  • A new stub:twilio/rest/__init__.pyi
  • Modified runtime module:twilio/rest/knowledge/v1/knowledge/__init__.py (type hints and policy handling in multipleto_dict methods)

Why

  • The.pyi stub improves IDE/autocomplete and prepares the codebase for static typing.
  • The runtime changes ensureto_dict() is correctly typed and avoid attribute errors whenpolicy objects do not implementto_dict().

Patch summary for knowledge module (selected excerpt)

Commit:e70d11f
Message: fix: add type hints and improve policy handling in to_dict methods

Diff excerpt:

--- a/twilio/rest/knowledge/v1/knowledge/init.py
+++ b/twilio/rest/knowledge/v1/knowledge/init.py
@@

  •    def to_dict(self):
  •    def to_dict(self) -> Dict[str, Any]:       return {           "description": self.description,           "knowledge_source_details": self.knowledge_source_details,           "name": self.name,
  •            "policy": self.policy.to_dict() if self.policy is not None else None,
  •            "policy": self.policy.to_dict() if (self.policy is not None and hasattr(self.policy, "to_dict")) else None,           "type": self.type,           "embedding_model": self.embedding_model,       }

(Repeated in multiple classes:KnowledgeInstance,KnowledgeContext,KnowledgeList — eachto_dict now has a-> Dict[str, Any] return annotation and saferpolicy handling.)

How to test

  • Run type checks and tests locally:
pip install -e .[dev]mypy twilio --follow-imports=silentpytest -q

Notes

  • The.pyi file is annotation-only and doesn't change runtime behavior.
  • The knowledge module changes are small, well-scoped runtime fixes; they should be safe but please run unit tests and smoke test features that usepolicy objects.

Suggested branch/commit

  • Branch:add/stubs/twilio-rest-client
  • Commit messages already present in history:914845712,e70d11fac

Requesting review from

  • @maintainers or module owners familiar withtwilio.rest andknowledge modules

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read theContribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please file asupport ticket, or create a GitHub Issue in this repository.

@al-chrisal-chris changed the titleAdd typed stub for twilio.rest.Client + to_dict type hints fixchore: Add typed stub for twilio.rest.Client + to_dict type hints fixDec 9, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@al-chris

[8]ページ先頭

©2009-2025 Movatter.jp