aisuite icon indicating copy to clipboard operation
aisuite copied to clipboard

Add and Expose Type Hints

Open chasleslr opened this issue 11 months ago • 3 comments

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

  1. Add Type Hints:

    • Review all functions, methods, and variables in the codebase and annotate them with appropriate type hints.
  2. Add py.typed File:

    • Include a py.typed file in the package to mark it as PEP 561-compatible.
  3. 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

chasleslr avatar Nov 28 '24 14:11 chasleslr

@chasleslr I would like to work on it.

OutstandingWork avatar Nov 29 '24 12:11 OutstandingWork

Thanks for the suggestion. We will investigate and see if it can be included in next release.

rohitprasad15 avatar Dec 07 '24 20:12 rohitprasad15

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.

zby avatar Dec 09 '24 21:12 zby