chore: fixed issued detected by mypy#30
Merged
Merged
Conversation
…decorator documentation
Contributor
There was a problem hiding this comment.
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
@overloaddecorators tostopwatch_decofor 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.
Contributor
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_decodecorator. The changes help simplify factory functions and make the stopwatch utility easier to use and understand.Type annotation simplification in factory functions:
create_key_monitor,create_sentence_generator, andcreate_user_interface, resulting in cleaner code infactory.pyfiles. [1] [2] [3]Enhancements to stopwatch utility:
overloaddecorators and comprehensive docstrings to thestopwatch_decofunction insimple_typing_application/utils/stopwatch.py, improving type safety and documentation for users of the decorator. [1] [2] [3]Minor code style improvements:
ainvokecall ingeneratewithinopenai_sentence_generator.py, making the code style more consistent.…decorator documentation