Skip to content
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

chore: type hint issue #537

Merged
merged 1 commit into from
Sep 8, 2023
Merged

Conversation

nautics889
Copy link
Contributor

@nautics889 nautics889 commented Sep 7, 2023

Minor fixes for type hints: List[CustomType] type doesn't seem to be an appropriate type when passing multiple arguments to a function.
See the screenshot below:
Screenshot 2023-09-07 230739
Instead, when covering asterisk arguments with type hints, i suggest to use Optional[CustomType] (Optional means that the function de-facto can accept 0 arguments).


Further notation: the Unpack type can appear in 3.12 according to PEP-0692, exactly for such cases.


  • (chore): inappropriate type for multiple function arguments (asterisk notation)
  • (docs): update docstring accordingly

Summary by CodeRabbit

  • Refactor: Updated the add_middlewares method in the PandasAI class across multiple modules (code_manager.py, smart_dataframe/__init__.py, and smart_datalake/__init__.py). The method now accepts an optional Middleware type instead of a list of Middleware. This change enhances flexibility when adding middlewares to the PandasAI instance, allowing users to add multiple middlewares as separate arguments rather than passing them as a list.

* (chore): inappropriate type for multiple function arguments (asterisk
  notation)
* (docs): update docstring accordingly
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 7, 2023

Walkthrough

The changes across the files primarily focus on enhancing the flexibility of the add_middlewares method in the PandasAI class. The method's signature has been updated to accept an optional Middleware type instead of a list, allowing for the addition of zero or more middlewares as arguments.

Changes

File Path Summary
.../helpers/code_manager.py Updated add_middlewares method to accept Optional[Middleware] instead of List[Middleware].
.../smart_dataframe/init.py Modified add_middlewares method to accept an optional Middleware type, increasing flexibility.
.../smart_datalake/init.py Changed add_middlewares method to accept multiple Middleware objects as separate arguments.

🐇💻

In the land of code where the shadows lie,

A rabbit hopped and tweaked a line.

No longer a list, but options galore,

Middleware now flexes more and more.

With each hop and skip, the code does grow,

Into a masterpiece, a radiant glow. 🌟


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 3

Commits Files that changed from the base of the PR and between 9e6a71a and ad7670c commits.
Files selected for processing (3)
  • pandasai/helpers/code_manager.py (1 hunks)
  • pandasai/smart_dataframe/init.py (1 hunks)
  • pandasai/smart_datalake/init.py (1 hunks)
Additional comments (Suppressed): 2
pandasai/smart_datalake/__init__.py (1)
  • 172-179: The function signature has been updated to accept an optional Middleware type instead of a list of Middleware. This change allows the method to accept zero or more middlewares as arguments, enhancing flexibility. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.
pandasai/helpers/code_manager.py (1)
  • 46-47:

pandasai/smart_dataframe/__init__.py Show resolved Hide resolved
pandasai/smart_datalake/__init__.py Show resolved Hide resolved
pandasai/helpers/code_manager.py Show resolved Hide resolved
@gventuri gventuri merged commit 1b5e942 into Sinaptik-AI:main Sep 8, 2023
9 checks passed
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.

2 participants