-
Notifications
You must be signed in to change notification settings - Fork 165
feat!: PEP 420 namespace migration for v2.0 #340
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Update version to 2.0.0a1 - Set moduleName to mistralai.client for PEP 420 namespace
Prepare for PEP 420 namespace migration by removing Speakeasy-generated files from src/mistralai/. Custom code in extra/ and _hooks/ is preserved. Speakeasy will regenerate the SDK under src/mistralai/client/.
- Update version to 2.0.0a1 - Update py.typed paths for new client/ location - Add mypy namespace_packages and explicit_package_bases settings
Generated by Speakeasy with moduleName=mistralai.client. All SDK code now lives under src/mistralai/client/.
- Move custom_user_agent.py, deprecation_warning.py, tracing.py - Update tracing.py to use absolute import for mistralai.extra - Update registration.py to register all custom hooks
Update all imports in src/mistralai/extra/ from: - mistralai.models -> mistralai.client.models - mistralai.types -> mistralai.client.types - mistralai.utils -> mistralai.client.utils - mistralai.sdkconfiguration -> mistralai.client.sdkconfiguration
Update all examples to use new import paths: - from mistralai import -> from mistralai.client import - from mistralai.models -> from mistralai.client.models - from mistralai.types -> from mistralai.client.types
- Update hooks path from _hooks/ to client/_hooks/ - Add check that src/mistralai/__init__.py must not exist (PEP 420)
Speakeasy's sdk-class-body regions were not copied when regenerating to the new mistralai.client namespace. Restored: - chat.py: parse, parse_async, parse_stream, parse_stream_async - conversations.py: run_async, run_stream_async - audio.py: realtime property Updated imports to use mistralai.client.* paths.
- chat.py: wrap custom imports in # region imports block - audio.py: wrap TYPE_CHECKING import in # region imports block - conversations.py: add pylint disable comments, fix else-after-break These markers ensure speakeasy regeneration preserves custom code.
- Auto-publish from v1 branch on RELEASES.md changes
- Require manual confirmation ("publish") for main branch deployments
- Prevents accidental v2.0.0 release before it's ready
This allows merging the v2 namespace migration to main safely while
maintaining v1.x releases from the v1 branch.
- Add v1→v2 section explaining PEP 420 namespace change - Explain motivation (azure/gcp companion packages) - Include automated migration sed commands - Preserve v0→v1 method mapping tables and examples
40c4974 to
48e7d75
Compare
|
Nice ! I don't think I have the knowledge to review much. Let me know if you want me to review some specifics |
dumontg
approved these changes
Feb 10, 2026
- Add null check for job.outputs to prevent crash when API returns no outputs - Add CANCELLED to terminal states - Add 5 minute timeout to prevent infinite polling
The original example used code_interpreter with differential equations, which caused timeouts and flaky CI failures. Simplified to "2+2" math. Original complex example preserved as async_conversation_run_code_interpreter.py and added to CI skip list (too slow/flaky for CI).
def9097 to
1f932e8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Migrates the SDK to a PEP 420 implicit namespace package structure.
Breaking change: Import paths updated from
mistralaitomistralai.client:Changes
PR 1 of N for v2.0 release
(Future PRs: update options, azure/gcp as namespace, collision detection...)
Local Testing
returns "OK! 😊 How can I assist you today?"
Test in test.pypi
(already published)
uv publish --publish-url https://test.pypi.org/legacy/ --token "$TEST_PYPI_TOKEN"https://test.pypi.org/project/mistralai/#history
uv run --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ --with mistralai==2.0.0a1 python -c " import os from mistralai.client import Mistral client = Mistral(api_key=os.environ['MISTRAL_API_KEY']) res = client.chat.complete(model='mistral-small-latest', messages=[{'role': 'user', 'content': 'Say OK'}]) print(res.choices[0].message.content) "-> "OK! 😊 How can I assist you today?"
Branching Strategy for v1/v2 Coexistence
This PR includes workflow changes to safely support both v1.x maintenance and v2.x development:
Branch Structure
v1mainWhat Changed
v1branch from currentmain(preserves v1.12.x codebase)v1but require manual confirmation frommainauto-generated PR now target v1: https://github.com/mistralai/dashboard/pull/16982After v2 Stabilization
When v2 is ready for release, restore auto-deploy by updating the workflow:
And remove the
ifcondition that blocks main branch auto-publish.Coverage Check
Details
Linear: https://linear.app/mistral-ai/issue/API-1961/pep-420-for-python-sdk-v2