Skip to content

chore: fixed issued detected by mypy#30

Merged
hmasdev merged 3 commits into
mainfrom
fix/fix-mypy-issue
Nov 16, 2025
Merged

chore: fixed issued detected by mypy#30
hmasdev merged 3 commits into
mainfrom
fix/fix-mypy-issue

Conversation

@hmasdev

@hmasdev hmasdev commented Nov 16, 2025

Copy link
Copy Markdown
Owner

This pull request introduces improvements to code clarity and type safety, primarily by removing redundant type annotations and enhancing the documentation and overloads for the stopwatch_deco decorator. The changes help simplify factory functions and make the stopwatch utility easier to use and understand.

Type annotation simplification in factory functions:

  • Removed redundant type annotations when assigning config objects in the factory functions create_key_monitor, create_sentence_generator, and create_user_interface, resulting in cleaner code in factory.py files. [1] [2] [3]

Enhancements to stopwatch utility:

  • Added overload decorators and comprehensive docstrings to the stopwatch_deco function in simple_typing_application/utils/stopwatch.py, improving type safety and documentation for users of the decorator. [1] [2] [3]

Minor code style improvements:

  • Adjusted argument formatting for the ainvoke call in generate within openai_sentence_generator.py, making the code style more consistent.…decorator documentation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves type safety and code clarity by adding @overload decorators to the stopwatch_deco function and refactoring type annotations in factory functions to follow a clearer pattern where variables are declared first, then assigned conditionally.

  • Added @overload decorators to stopwatch_deco for better type inference when used with and without parentheses
  • Refactored type annotations in factory functions to declare variables before conditional assignment
  • Minor code style improvement in openai_sentence_generator.py

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
simple_typing_application/utils/stopwatch.py Added overload import and two overload signatures with docstrings for stopwatch_deco to support both decorator usage patterns
simple_typing_application/ui/factory.py Moved type annotation for user_interface_config to declaration before the conditional block
simple_typing_application/sentence_generator/factory.py Moved type annotation for sentence_generator_config to declaration before the conditional block
simple_typing_application/key_monitor/factory.py Moved type annotation for key_monitor_config to declaration before the conditional block
simple_typing_application/sentence_generator/openai_sentence_generator.py Moved # type: ignore comment to the same line as the dictionary argument for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread simple_typing_application/utils/stopwatch.py Outdated
Comment thread simple_typing_application/utils/stopwatch.py Outdated
Comment thread simple_typing_application/utils/stopwatch.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

simple_typing_application/utils/stopwatch.py:139

  • The return type description in the main implementation's docstring is incomplete and incorrect. It should document both possible return types: 'Callable[P, T] | Callable[[Callable[P, T]], Callable[P, T]]: Either a decorated function (when func is provided) or a decorator (when func is None).'.
        Callable[P, T]: decorated function.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread simple_typing_application/utils/stopwatch.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hmasdev hmasdev merged commit e8a4205 into main Nov 16, 2025
23 checks passed
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