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

Implement proper type hinting #32

Merged

Conversation

Zingzy
Copy link
Owner

@Zingzy Zingzy commented Nov 27, 2024

This PR addresses Issue #30

Summary by Sourcery

Enhancements:

  • Add type hints to various functions and methods to improve code readability and maintainability.

@Zingzy Zingzy self-assigned this Nov 27, 2024
@Zingzy Zingzy linked an issue Nov 27, 2024 that may be closed by this pull request
Copy link

sourcery-ai bot commented Nov 27, 2024

Reviewer's Guide by Sourcery

This PR implements proper type hinting throughout the codebase, improving code readability and maintainability. The changes include adding type annotations to function parameters and variables, using proper Union types for multiple type options, and formatting code according to Python style guidelines.

Updated class diagram for type hinting

classDiagram
    class title_bar {
        +hide(window: Any) None
        +unhide(window: Any) None
    }
    class maximize_minimize_button {
        +hide(window: Any) None
        +unhide(window: Any) None
    }
    class maximize_button {
        +disable(window: Any) None
        +enable(window: Any) None
    }
    class minimize_button {
        +disable(window: Any) None
        +enable(window: Any) None
    }
    class all_stuffs {
        +hide(window: Any) None
        +unhide(window: Any) None
    }
    class window_flash {
        +flash(window: Any, count: int = 5, interval: int = 1000) None
        +stop(window: Any) None
    }
    class opacity {
        +set(window: Any, opacity: float) None
    }
    class title_bar_color {
        +set(window: Any, color: Union[Tuple[int, int, int], str]) None
        +set_accent(window: Any) None
        +reset(window: Any) None
    }
    class title_bar_text_color {
        +set(window: Any, color: Union[Tuple[int, int, int], str]) None
        +reset(window: Any) None
    }
    class border_color {
        +set(window: Any, color: Union[Tuple[int, int, int], str]) None
        +set_accent(window: Any) None
        +reset(window: Any) None
    }
    class rainbow_title_bar {
        +start(window: Any, interval: int = 5, color_stops: int = 5) None
        +stop(window: Any) None
    }
    class rainbow_border {
        +start(window: Any, interval: int = 5, color_stops: int = 5) None
        +stop(window: Any) None
    }
    class window_frame {
        +center(window: Any) None
        +center_relative(window_parent: Any, window_child: Any) None
        +move(window: Any, x: int, y: int) None
        +resize(window: Any, width: int, height: int) None
        +minimize(window: Any) None
        +maximize(window: Any) None
        +restore(window: Any) None
    }
    class window_animation {
        +circle_motion(window: Any, count: int = 5, interval: int = 5, radius: int = 20) None
        +vertical_shake(window: Any, count: int = 5, interval: int = 3, amplitude: int = 20) None
        +horizontal_shake(window: Any, count: int = 5, interval: int = 3, amplitude: int = 20) None
    }
    class title_text {
        +set(window: Any, title: str) None
        +stylize(window: Any, style: int = 1) None
        +reset(window: Any) None
    }
    class convert_color {
        +convert_color(color: Union[Tuple[int, int, int], str]) int
    }
    class module_find {
        +module_find(window: Any) int
    }
Loading

File-Level Changes

Change Details Files
Added type hints to function parameters and return values
  • Added 'Any' type hint for window parameters across all classes
  • Added 'int' type hints for numeric parameters
  • Added 'str' type hints for string parameters
  • Added proper return type annotations to functions
hPyT/hPyT.py
Improved type annotations for global variables and data structures
  • Added List[int] type hints for global list variables
  • Added dict type hint for the titles dictionary
  • Added proper type hints for class attributes and local variables
hPyT/hPyT.py
Implemented Union types for parameters accepting multiple types
  • Added Union[Tuple[int, int, int], str] type hint for color parameters
  • Updated function signatures to properly handle multiple input types
hPyT/hPyT.py
Applied code formatting improvements
  • Fixed line wrapping for long function calls
  • Added proper spacing around operators
  • Improved exception handling with specific Exception catches
  • Removed trailing whitespace
hPyT/hPyT.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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

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

@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 @Zingzy - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 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.

hPyT/hPyT.py Show resolved Hide resolved
@Zingzy Zingzy merged commit 2414a10 into main Nov 27, 2024
@Zingzy Zingzy deleted the 30-use-proper-typing-extensions-to-make-python-38-compatible branch December 1, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use proper typing extensions to make python 3.8 compatible
1 participant