-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add pyright to project. Fix errors reported by pyright. #29
Merged
Conversation
This file contains 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
Adjust pyproject.toml formatting
Add pyright settings to pyproject.toml
Add default value for header in create_cards_from_tsv(). header parameter is unpacked and must be initialised to an empty dictionary if None.
Fix compatibility of Seakable protocol with builtin IOWrapper class. Note: This signature may not be compatible with all Seekable type objects
Fix improper usage of TypeVars
Add option to Gaggle.iml to seek a JDK named "Python 3.11 (Gaggle)" with the Python SDK rather than inheriting.
Add pyright version to pyproject.toml Pin new dependencies
Remove unnecessary typing.cast() calls
Add missing type hints to LeftoverArgumentWarning.__init__() Add missing type hints to LeftoverArgumentWarning._create_message()
Add missing type hints to wrapper function propagate_warnings()
Remove declaration of propagate_warnings_yield() Add functionality of propagate_warnings_yield to propagate_warnings() using optional bool parameter yields.
Add ignore for pyright false positive. Throwing error over name of deck and deck_idx parameters for write_deck_to_file() overloads. Naming difference follows convention shown as example in PEP 484.
Specify row as Iterable[str] in writerow() for Protocol class.
Yapf formatting
This reverts commit 956c7ec.
Remove yields parameter from propagate_warnings
Add overload function definitions to _initialise_decks() Add type hints to parameters in _initialise_decks()
Change return value of _generate_unique_file_path() from the unique file name to the unique path.
Make type of returned empty list explicit.
Add type hint for parameters of _generate_unique_file_path()
Fix type hint for generate_flattened_kwargs_fill_missing(). fillvalue now correctly reflected in return type hint.
Make end of positional arguments explicit.
Add typevar to type hint of generate_flattened_kwargs_remove_falsy()
Add TypeVar to fillvalue in type hint. Update return type
Add type hints to AnkiDeck.from_file() class method.
Add type hints to Gaggle.add_deck()
Add type hints to write_deck_to_file() definition
Remove function _get_num_decks. Unnecessary decomposition.
Add type hint to Gaggle.get_deck()
Remove unnecessary function Gaggle._get_decks(). Property self.decks is public.
Add explicit type hint for Gaggle.decks()
Add type hint to transform_integer_value()
Update type hint for transform_integer_value. Add extra overload to cover previously uncovered case.
Add type hint to _copy_and_reformat
yapf formatting
Project previously shadowed several builtin types from typing and _typeshed. Switch to using builtin types.
Remove pyright suppression comments
Assert to ensure value is internally consistent for typing.
Fix type hints related to has_html in AnkiHeader protocol.
Add type hint for deck constructed from list literal in create_cards_from_tsv().
Add type hint to get_field()
Add explicit type hint to str_list in as_str_list()
Fix type hint for return value of _copy_and_reformat()
Type hint propagate_warnings() function Type hint propagate_warnings_from_generator() function
Add explicit type hint for dictionary literal {} in write_all_decks_to_file() Remove unnecessary overload functions. Return values were consistent between both calls.
Remove unnecessary overload function type hints for _initialise_decks()
Generate stub files for gaggle using pyright. Document public functions.
Set reportUntypedFunctionDecorator to true for pyright. Set reportUntypedClassDecorator to true for pyright.
yapf formatting
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.
What?
1.Add pyright to Gaggle.
2.Fix type hints in Gaggle.
3.Remove unnecessary functions.
Why?
1.2.pyright allows static analysis of types and helps improve documentation.
2.Various type hints were incorrect or superfluous in Gaggle.
1.2.3.Improve maintainability.
How?
1.Add pyright to
pyproject.toml
dev dependencies and update poetry.lock. pyright set to do strict type checking for files in src/gaggle.2.Run
pyright
naked command;pyproject.toml
handles all required settings. Fixed and added type hints until no preventable static analysis errors were returned.3. Corrected various bugs exposed when correcting type hinting. Removed unnecessary getter functions (one line, zero complexity functions).
Testing?
Code passes scratch file used as short term testing.
Screenshots (optional)
0
Anything Else?
There are currently two cases of reported errors from pyright. The first is a bug which will be patched in the next release version, see this issue in the pyright repository for more information.
The second case of error is with AnkiHeader. Due to having the typing of
str | int | None
certain strict type checks return errors. This will be corrected when [#27] is finished.Created from JetBrains using CodeStream