aisuite
aisuite copied to clipboard
Add and Expose Type Hints
Summary
Add type hints to the codebase. This includes adding a py.typed file (as per PEP 561) to enable type checkers to use aisuite's type information effectively.
Why is this needed?
- Improves code readability and maintainability by explicitly defining function signatures and variable types.
- Enables mypy, pyright, and other type checkers to utilize
aisuite's type information when users check their code. - Provides completion suggestions for users of pylance or pyright.
Proposed Solution
-
Add Type Hints:
- Review all functions, methods, and variables in the codebase and annotate them with appropriate type hints.
-
Add py.typed File:
- Include a py.typed file in the package to mark it as PEP 561-compatible.
-
Integrate mypy:
- Add mypy as a development dependency in the project.
- Configure a mypy.ini file or equivalent to define type-checking rules.
- Ensure mypy checks are part of the CI pipeline.
Additional Context
- Reference: PEP 484 - Type Hints
- Reference: PEP 561 - Distributing and Packaging Type Information
- Reference: mypy Documentation
@chasleslr I would like to work on it.
Thanks for the suggestion. We will investigate and see if it can be included in next release.
This is not an easy task - you need to unify all the types returned by the different providers. For example what should be the return type of 'client.chat.completions.create' call and in particular of the choices[0].message field of that object?
But it would be very very useful if we got these unified types - without that you never know what fields to expect and even if it is an object or just a dictionary.