π¨ Fix incompatible types assignment in main function signature
The following error in mypy is a result of re-assigning
arguments:
error: Incompatible types in assignment (expression has type
"Namespace", variable has type "Optional[List[str]]") [assignment]
The solution is to avoid the use of the pattern that argparse
suggests, because it causes type shadowing that is hard for humans and
hard for mypy to read. The following resource does a good job
explaining the problem and solution:
Test do not pass, but that will be handled in a different PR.
π Reviewer Checklist
[x] Run tox -e mypy to see that the code is now type-hinted correctly.
β PR Checklist
[x] Remove or update the PR template boilerplate text
[x] Reviewers Requested
[x] Labels added
[x] Projects associated
[x] Milestone assigned
[x] All docstrings are formatted as google docstrings with filled out types and explanations; Any code that was edited and contains a prose description of the functional execution, and preferably a doctest compatible example
[x] Docstring examples are all doctest compliant
[x] Any file or folder names are manipulated via pathlib.Path
[x] Non-public imports and API elements are prefixed with a single underscore or the package __all__ variable is set
[x] All noqa statements for skipping lint rules are justified
[x] Commits mention issue and/or PR numbers at the bottom of the message with the Username/Repository# format
[x] Relevant issues are linked into the PR (issues mentioned in overview should link for you)
[x] TODOs are completed
[x] Reviewer checklist is updated
π TODOs
[x] None
π Future Work
Tests do not pass and will be addressed in a future PR.
π°οΈ Overview
Fix
mypy
typing errors in the codebase. There are no functional adjustments being made to the code.β¨ Change Description/Rationale
no_implicit_optional
type hinting errorPEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to
no_implicit_optional=True
The tool https://github.com/hauntsaninja/no_implicit_optional was used to automatically upgrade the codebase.
main
function signatureThe following error in
mypy
is a result of re-assigningarguments
:error: Incompatible types in assignment (expression has type "Namespace", variable has type "Optional[List[str]]") [assignment]
The solution is to avoid the use of the pattern that
argparse
suggests, because it causes type shadowing that is hard for humans and hard formypy
to read. The following resource does a good job explaining the problem and solution:https://adamj.eu/tech/2021/05/23/python-type-hints-mypy-doesnt-allow-variables-to-change-type/
π§ͺ Test Coverage
There are no changes relevant to this section.
π¨ Quality Deviations
Test do not pass, but that will be handled in a different PR.
π Reviewer Checklist
tox -e mypy
to see that the code is now type-hinted correctly.β PR Checklist
doctest
compatible exampledoctest
compliantpathlib.Path
__all__
variable is setnoqa
statements for skipping lint rules are justifiedπ TODOs
π Future Work