LemurPwned / video-sampler

Effective frame sampling for ML applications.
https://lemurpwned.github.io/video-sampler/
MIT License
16 stars 5 forks source link

simplification of imports #31

Closed LemurPwned closed 3 weeks ago

LemurPwned commented 3 weeks ago

Summary by Sourcery

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

Enhancements:

sourcery-ai[bot] commented 3 weeks ago

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

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](https://app.sourcery.ai) 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 - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).