-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
Some collected cleanups #435
Open
MaxG87
wants to merge
14
commits into
jazzband:master
Choose a base branch
from
MaxG87:cleanups
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+136
−61
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
The added type hints are required to prevent a mypy complaint later on.
The documentation of click.ParamType states that `ParamType.convert` will never get a parameter `value` that is `None` [1]. Therefore, the entire branching can be removed. With it, the implicit return of None is removed too. [1]: https://click.palletsprojects.com/en/8.0.x/api/#click.ParamType.convert
A bit of guessing was involved. In one case a potential bug was uncovered: If the raw string for `stop` was empty, the initialisation of the stop time would have been skipped. This is fixed right ahead.
A classmethod `make_new` is introduced and used throughout the code. This prepares rewriting the class to a typed NamedTuple.
Using typing.NamedTuple has plenty of advantages over collections.namedtuple. The most important is that now HEADERS is not required anymore for class construction.
Its relevant only in Python 2.7.
Now that all very obvious type problems are resolved, mypy can be used in the static analysis part.
I force pushed fixes for the overly long lines. |
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.
When I wanted to work on some bug that keeps nagging me, I noticed that support or Python 3.5 was dropped. I also noticed some minor negligencese I could not resist to improve.
This PR resolves these negligences and adds static analysis by
mypy
. Mypy mostly checks static types but can detect also some other problems like tatulogical conditions or unreachable code.Please note that while complete this PR is also a kind of RFC. If it is accepted, I might add some more type hints and the related refactorings with further PRs. So feel free to nit-pick a lot here ;-).