Skip to content
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

Finish adding mypy type checking #214

Open
nreinicke opened this issue May 17, 2024 · 1 comment · May be fixed by #227
Open

Finish adding mypy type checking #214

nreinicke opened this issue May 17, 2024 · 1 comment · May be fixed by #227
Labels
python Applies to the python code
Milestone

Comments

@nreinicke
Copy link
Collaborator

We've started adding type hints to the python wrapper of the app but haven't gotten full coverage. Add in any missing types and then we can activate the mypy check in our GitHub action.

@nreinicke nreinicke added this to the PyCon 2024 milestone May 17, 2024
@nreinicke nreinicke added the python Applies to the python code label May 17, 2024
@nreinicke nreinicke changed the title Add mypy type checking Finish adding mypy type checking May 17, 2024
@SnoopJ
Copy link
Contributor

SnoopJ commented May 20, 2024

I'll take this one. I don't get any errors from mypy after installing the type stubs for what's needed, but if I add --strict I see a bunch of errors:

click for mypy errors
$ python3 -m mypy --strict python/
python/nrel/routee/compass/plot/plot_utils.py:2: error: Function is missing a type annotation  [no-untyped-def]
python/nrel/routee/compass/plot/plot_utils.py:7: error: Function is missing a type annotation  [no-untyped-def]
python/nrel/routee/compass/plot/plot_utils.py:10: error: Function is missing a return type annotation  [no-untyped-def]
python/nrel/routee/compass/plot/plot_utils.py:15: error: Call to untyped function "rgba_to_hex" in typed context  [no-untyped-call]
python/nrel/routee/compass/plot/plot_utils.py:20: error: Function is missing a type annotation  [no-untyped-def]
python/nrel/routee/compass/compass_app.py:33: error: Function is missing a return type annotation  [no-untyped-def]
python/nrel/routee/compass/compass_app.py:69: error: Missing type parameters for generic type "Dict"  [type-arg]
python/nrel/routee/compass/compass_app.py:87: error: Call to untyped function "get_constructor" of "CompassApp" in typed context  [no-untyped-call]
python/nrel/routee/compass/compass_app.py:91: error: Missing type parameters for generic type "Dict"  [type-arg]
python/nrel/routee/compass/compass_app.py:135: error: Returning Any from function declared to return "list[dict[str, Any]]"  [no-any-return]
python/nrel/routee/compass/compass_app.py:148: error: Returning Any from function declared to return "int"  [no-any-return]
python/nrel/routee/compass/compass_app.py:160: error: Returning Any from function declared to return "int"  [no-any-return]
python/nrel/routee/compass/compass_app.py:175: error: Returning Any from function declared to return "float"  [no-any-return]
python/nrel/routee/compass/compass_app.py:187: error: Returning Any from function declared to return "list[int]"  [no-any-return]
python/nrel/routee/compass/compass_app.py:199: error: Returning Any from function declared to return "list[int]"  [no-any-return]
python/nrel/routee/compass/io/generate_dataset.py:14: error: Function is missing a return type annotation  [no-untyped-def]
python/nrel/routee/compass/io/generate_dataset.py:14: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
python/nrel/routee/compass/io/generate_dataset.py:17: error: Missing type parameters for generic type "Dict"  [type-arg]
python/nrel/routee/compass/io/generate_dataset.py:19: error: Missing type parameters for generic type "Callable"  [type-arg]
python/nrel/routee/compass/io/generate_dataset.py:98: error: Function is missing a type annotation  [no-untyped-def]
python/tests/test_downtown_denver_example.py:8: error: Function is missing a return type annotation  [no-untyped-def]
python/tests/test_downtown_denver_example.py:8: note: Use "-> None" if function does not return a value
python/tests/test_downtown_denver_example.py:27: error: Non-overlapping container check (element type: "str", container item type: "dict[str, Any]")  [comparison-overlap]
python/nrel/routee/compass/io/utils.py:66: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
python/nrel/routee/compass/io/utils.py:75: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
python/nrel/routee/compass/io/utils.py:107: error: Function is missing a return type annotation  [no-untyped-def]
python/nrel/routee/compass/io/utils.py:107: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
python/nrel/routee/compass/plot/plot_folium.py:16: error: Function is missing a return type annotation  [no-untyped-def]
python/nrel/routee/compass/plot/plot_folium.py:16: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
python/nrel/routee/compass/plot/plot_folium.py:17: error: Missing type parameters for generic type "dict"  [type-arg]
python/nrel/routee/compass/plot/plot_folium.py:18: error: Missing type parameters for generic type "dict"  [type-arg]
python/nrel/routee/compass/plot/plot_folium.py:122: error: Function is missing a return type annotation  [no-untyped-def]
python/nrel/routee/compass/plot/plot_folium.py:123: error: Missing type parameters for generic type "dict"  [type-arg]
python/nrel/routee/compass/plot/plot_folium.py:124: error: Missing type parameters for generic type "dict"  [type-arg]
python/nrel/routee/compass/plot/plot_folium.py:168: error: Call to untyped function "rgba_to_hex" in typed context  [no-untyped-call]
python/nrel/routee/compass/plot/plot_folium.py:170: error: Call to untyped function "ColormapCircularIterator" in typed context  [no-untyped-call]
Found 35 errors in 6 files (checked 11 source files)

After discussing with Nick, probably the check should be updated to add --strict since the goal of this is complete typing of the API. (I'm not sure if --install-types will make sense for the check or if that dependency on the type stubs should be declared explicitly somewhere)

@SnoopJ SnoopJ linked a pull request May 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Applies to the python code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants