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

simplification of imports #31

Closed
wants to merge 1 commit into from
Closed

simplification of imports #31

wants to merge 1 commit into from

Conversation

LemurPwned
Copy link
Owner

@LemurPwned LemurPwned commented Oct 3, 2024

Summary by Sourcery

Simplify import statements by using contextlib to handle optional dependencies and update type hinting for a method parameter.

Enhancements:

  • Simplify import statements by using contextlib to suppress ImportError for optional dependencies pysrt and spacy.

Copy link
Contributor

sourcery-ai bot commented Oct 3, 2024

Reviewer's Guide by Sourcery

This pull request simplifies imports and makes minor adjustments to improve code organization and type hinting. The changes focus on conditional imports, error handling, and type annotations.

Class diagram for updated imports and type hinting

classDiagram
    class KeywordCapture {
        +contextlib
        +collections
        +collections.abc
        +requests
        +requests.exceptions
        +pysrt
        +spacy
        +Color
        +console
    }
    class Gating {
        +_embed_frames(frames: list[Image.Image])
        +_get_margins(frame_embeds: "torch.Tensor")
    }
    KeywordCapture --> Gating : uses
    KeywordCapture : +subtitle_line
    Gating : +_embed_frames
    Gating : +_get_margins
Loading

File-Level Changes

Change Details Files
Implement conditional imports for optional dependencies
  • Add contextlib import
  • Move pysrt and spacy imports inside a contextlib.suppress(ImportError) block
  • Remove direct imports of pysrt and spacy from the top of the file
video_sampler/language/keyword_capture.py
Improve type hinting
  • Add quotes around 'torch.Tensor' in the _get_margins method signature
video_sampler/gating.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @LemurPwned - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider separating the suppressed imports for pysrt and spacy. This would allow for more granular error handling if one package is available but the other isn't.
  • Can you clarify why the torch.Tensor type hint needed to be quoted? Is there a circular import issue, or is it not available at runtime?
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LemurPwned LemurPwned closed this Oct 3, 2024
@LemurPwned LemurPwned deleted the feat/fix-imports branch October 3, 2024 10:56
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.

1 participant