Skip to content

dev/issues-10 - #205

Open
luk384090-cloud wants to merge 5 commits into
mainfrom
dev/issues-10
Open

luk384090-cloud wants to merge 5 commits into
mainfrom
dev/issues-10

Conversation

@luk384090-cloud

@luk384090-cloud luk384090-cloud commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR contains two changes:

1. Refactor Assistants API imports to lazy loading (Fixes #207)

The dashscope.assistants / dashscope.threads modules have been marked as deprecated, but previously a plain import dashscope would unconditionally import these modules, causing all users to see DeprecationWarning even if they never used the Assistants API.

Changes: Removed static imports of these modules from __init__.py and switched to PEP 562 __getattr__ mechanism for on-demand loading. Import and deprecation warnings are only triggered when names like dashscope.Messages, dashscope.Runs are actually accessed.

  • Added _DEPRECATED_LAZY_IMPORTS mapping table and __getattr__ / __dir__ implementation
  • Added test_import_deprecation.py unit tests to cover lazy loading behavior

2. Fix Encryption using global api_key

The Encryption class previously hardcoded dashscope.base_http_api_url and dashscope.api_key global variables, causing base_url / api_key passed as function parameters to be ignored in encryption scenarios.

Changes: Added optional base_url and api_key parameters to Encryption.__init__, and api_request_factory now passes the current call's credentials when creating instances.

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.

DeprecationWarning emitted on plain import dashscope (Assistants API import in __init__.py)

1 participant