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

Reblacken code after #8360 #8609

Merged
merged 1 commit into from
Oct 29, 2024
Merged

Reblacken code after #8360 #8609

merged 1 commit into from
Oct 29, 2024

Conversation

SpecLad
Copy link
Contributor

@SpecLad SpecLad commented Oct 29, 2024

Motivation and context

Starting with Python 3.9, with allows parenthesized context managers, which black will use when needed.

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • [ ] I have created a changelog fragment
  • [ ] I have updated the documentation accordingly
  • [ ] I have added tests to cover my changes
  • [ ] I have linked related issues (see GitHub docs)
  • [ ] I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • Chores
    • Improved code readability by restructuring context managers and file handling in the Downloader class and create_compose_files function.
    • Minor adjustments made to comments and formatting for consistency.

Copy link
Contributor

coderabbitai bot commented Oct 29, 2024

Walkthrough

The changes involve modifications to the download_file method in the Downloader class of cvat_sdk/core/downloading.py and the create_compose_files function in tests/python/shared/fixtures/init.py. The download_file method's context manager has been restructured for better readability without altering its functionality. Similarly, the create_compose_files function now opens file handles using a single with statement instead of sequentially, enhancing clarity while maintaining existing logic and control flow.

Changes

File Path Change Summary
cvat_sdk/core/downloading.py Restructured context manager in download_file method for improved readability; functionality unchanged.
tests/python/shared/fixtures/init.py Consolidated file opening in create_compose_files into a single with statement; minor formatting adjustments.

Poem

In the code where bunnies hop,
Clarity blooms, no need to stop.
With files now opened, side by side,
Readable paths, we take in stride.
A leap of joy in every line,
For clearer code, we dance and shine! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9982156 and 126ecdc.

📒 Files selected for processing (2)
  • cvat-sdk/cvat_sdk/core/downloading.py (1 hunks)
  • tests/python/shared/fixtures/init.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • cvat-sdk/cvat_sdk/core/downloading.py
🔇 Additional comments (1)
tests/python/shared/fixtures/init.py (1)

303-306: LGTM! Clean use of parenthesized context managers.

The consolidation of file operations into a single with statement improves readability while maintaining the same functionality. Just note that this syntax requires Python 3.9 or later.

Let's verify the Python version requirement is met:

✅ Verification successful

Python 3.9 requirement is met, change is safe to use

The codebase explicitly targets Python 3.9 as confirmed in pyproject.toml's black configuration (target-version = ['py39']), so the use of parenthesized context managers (Python 3.9+ feature) in the test fixtures is appropriate and safe.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check Python version in the project
rg -g "setup.py|pyproject.toml|requirements*.txt" "python.*version" -A 5

Length of output: 223


Script:

#!/bin/bash
# Let's try different approaches to find Python version requirements
# 1. Look for pyproject.toml with different case
fd -i "pyproject.toml"

# 2. Look for any setup files
fd -i "setup.py"

# 3. Look for requirements files
fd -i "requirements"

# 4. Check for Python version in tox.ini if it exists
fd -i "tox.ini"

# 5. Look for CI configuration files that might specify Python version
fd -i ".python-version"
fd -e yml -e yaml | grep -i "github\|gitlab\|azure"

Length of output: 643


Script:

#!/bin/bash
# Let's check the Python version requirements in the found files
cat pyproject.toml tests/python/pyproject.toml tests/python/requirements.txt 2>/dev/null | grep -i "python"

# Also check the GitHub workflow files specifically for Python version
fd -e yml -e yaml -d 1 -p .github/workflows/ | xargs cat 2>/dev/null | grep -A 5 -B 5 "python-version"

Length of output: 209


Script:

#!/bin/bash
# Let's check the content of the test file itself for any Python version hints
cat tests/python/shared/fixtures/init.py | grep -B 5 -A 5 "import" 

# Also check the main pyproject.toml content fully
cat pyproject.toml

# And check the test's pyproject.toml
cat tests/python/pyproject.toml

Length of output: 1351


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

Copy link

sonarcloud bot commented Oct 29, 2024

@SpecLad
Copy link
Contributor Author

SpecLad commented Oct 29, 2024

@Marishka17 FYI.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.19%. Comparing base (251054b) to head (126ecdc).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8609      +/-   ##
===========================================
- Coverage    74.20%   74.19%   -0.01%     
===========================================
  Files          403      403              
  Lines        43375    43375              
  Branches      3925     3925              
===========================================
- Hits         32185    32181       -4     
- Misses       11190    11194       +4     
Components Coverage Δ
cvat-ui 78.55% <ø> (-0.03%) ⬇️
cvat-server 70.47% <0.00%> (ø)

@SpecLad SpecLad merged commit bce96ea into cvat-ai:develop Oct 29, 2024
35 checks passed
@SpecLad SpecLad deleted the reblacken branch October 29, 2024 16:18
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