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

move linter&formatter to Ruff, reformat codebase and fix some bugs #533

Merged
merged 9 commits into from
Apr 30, 2024

Conversation

ocss884
Copy link
Member

@ocss884 ocss884 commented Apr 26, 2024

close #509
The majority of changes are about formatting, except that

  • clarify which warnings are intended to be suppressed in all type-ignore
  • Improve import statement, instead of import from module __init__, use absolute import if they are under a same module.
  • fix a bug in Opensourceconfig which initializes instance variable with mutable dataclass
  • find children retriever class breaks LSP, will be fixed in fix: retriever module follow LSP, utils function use GPT_3_5_TURBO #532

@ocss884 ocss884 requested a review from a team April 26, 2024 00:55
Copy link

coderabbitai bot commented Apr 26, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ocss884 ocss884 changed the title reformat codebase and fix some bugs move linter&formatter to Ruff, reformat codebase and fix some bugs Apr 26, 2024
@Wendong-Fan Wendong-Fan added the enhancement New feature or request label Apr 28, 2024
@Wendong-Fan Wendong-Fan added this to the Sprint 2 milestone Apr 28, 2024
Copy link
Member

@Appointat Appointat left a comment

Choose a reason for hiding this comment

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

I noticed that some lines of code exceed 80 characters, which violates Python's programming standards. Please ensure you run the pre-commit install command before submitting your code (see CONTRIBUTION.md for details).

Additionally, I strongly recommend double-checking your code format before submitting the PR. I paused my review due to this issue, but once you confirm that it has been adjusted to meet Python standards in terms of formatting, please let me know and I will resume the review. Thank you for your understanding.

apps/agents/test/test_text_utils.py Show resolved Hide resolved
apps/agents/test/test_text_utils.py Show resolved Hide resolved
apps/data_explorer/test/test_data_explorer.py Outdated Show resolved Hide resolved
Comment on lines +93 to +101
default_dataset_name = (
default_dataset
if default_dataset in datasets.keys()
else ordinary_datasets[0]
if len(ordinary_datasets) > 0
else misalignment_datasets[0]
if len(misalignment_datasets) > 0
else ""
)
Copy link
Member

Choose a reason for hiding this comment

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

Is the code block more readable as:

Suggested change
default_dataset_name = (
default_dataset
if default_dataset in datasets.keys()
else ordinary_datasets[0]
if len(ordinary_datasets) > 0
else misalignment_datasets[0]
if len(misalignment_datasets) > 0
else ""
)
# Determine the default dataset name
if default_dataset in datasets:
default_dataset_name = default_dataset
elif ordinary_datasets:
default_dataset_name = ordinary_datasets[0]
elif misalignment_datasets:
default_dataset_name = misalignment_datasets[0]
else:
default_dataset_name = ""

camel/agents/chat_agent.py Outdated Show resolved Hide resolved
@ocss884
Copy link
Member Author

ocss884 commented Apr 28, 2024

I noticed that some lines of code exceed 80 characters, which violates Python's programming standards. Please ensure you run the pre-commit install command before submitting your code (see CONTRIBUTION.md for details).

Additionally, I strongly recommend double-checking your code format before submitting the PR. I paused my review due to this issue, but once you confirm that it has been adjusted to meet Python standards in terms of formatting, please let me know and I will resume the review. Thank you for your understanding.

It is desired since we move the formatter to ruff. 88 is the default of black/ruff and yes many famous projects, including some python official standard libraries, have discarded the original line limit 79 from pep8 now.

@Appointat
Copy link
Member

I noticed that some lines of code exceed 80 characters, which violates Python's programming standards. Please ensure you run the pre-commit install command before submitting your code (see CONTRIBUTION.md for details).
Additionally, I strongly recommend double-checking your code format before submitting the PR. I paused my review due to this issue, but once you confirm that it has been adjusted to meet Python standards in terms of formatting, please let me know and I will resume the review. Thank you for your understanding.

It is desired since we move the formatter to ruff. 88 is the default of black/ruff and yes many famous projects, including some python official standard libraries, have discarded the original line limit 79 from pep8 now.

Thanks for your reply. Could you please update the contributing.md, since we use ruff?

@ocss884
Copy link
Member Author

ocss884 commented Apr 29, 2024

I noticed that some lines of code exceed 80 characters, which violates Python's programming standards. Please ensure you run the pre-commit install command before submitting your code (see CONTRIBUTION.md for details).
Additionally, I strongly recommend double-checking your code format before submitting the PR. I paused my review due to this issue, but once you confirm that it has been adjusted to meet Python standards in terms of formatting, please let me know and I will resume the review. Thank you for your understanding.

It is desired since we move the formatter to ruff. 88 is the default of black/ruff and yes many famous projects, including some python official standard libraries, have discarded the original line limit 79 from pep8 now.

Thanks for your reply. Could you please update the contributing.md, since we use ruff?

Just ask guohao and we decide to switch the character limit back to 80 as in google python guide. README.md is updated now

Copy link
Member

@Appointat Appointat left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@ocss884 ocss884 merged commit 7dd4a2a into master Apr 30, 2024
6 checks passed
@ocss884 ocss884 deleted the feature/move-to-ruff branch April 30, 2024 08:05
@Appointat
Copy link
Member

Hi @ocss884, could you please resolve all conversations before merging the PR in the future, whether you accept or reject the comments? This helps prevent any misunderstandings. Thanks a lot! :)

Click "Resolve conversation":
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Merged or Closed
Development

Successfully merging this pull request may close these issues.

[Feature Request] Move to Ruff
3 participants