SterlingPeet / arduino-cli-cmake-wrapper

Arduino Cmake toolchain leveraging ``arduino-cli`` via python wrapper script
Other
1 stars 0 forks source link

Fix ``mypy`` Errors #2

Closed SterlingPeet closed 1 year ago

SterlingPeet commented 1 year ago

πŸ›°οΈ Overview

Fix mypy typing errors in the codebase. There are no functional adjustments being made to the code.

✨ Change Description/Rationale

PEP 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.

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:

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

βœ… PR Checklist

πŸš€ TODOs

πŸ“Œ Future Work

SterlingPeet commented 1 year ago

@LeStarch I have added you to this PR largely because it serves as an example of how PRs should look for this repo.