Fix mypy test failures
christophebedard opened this issue · 2 comments
In tracetools_launch
:
tracetools_launch/actions/ld_preload.py:23:1: error: Module "launch" has no attribute "logging" [attr-defined]
tracetools_launch/action.py:28:1: error: Module "launch" has no attribute "logging" [attr-defined]
test/tracetools_launch/test_ld_preload_action.py:21:1: error: Module "launch" has no attribute "LaunchDescription" [attr-defined]
test/tracetools_launch/test_ld_preload_action.py:22:1: error: Module "launch" has no attribute "LaunchService" [attr-defined]
launch/example.launch.py:17:1: error: Module "launch" has no attribute "LaunchDescription" [attr-defined]
Found 5 errors in 4 files (checked 13 source files)
and tracetools_test
:
tracetools_test/case.py: note: In member "assertMatchingField" of class "TraceTestCase":
tracetools_test/case.py:318:36: error: Incompatible default for argument "matching_event_name" (default has type "None", argument has type "str") [assignment]
tracetools_test/case.py:318:36: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
tracetools_test/case.py:318:36: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
tracetools_test/case.py:319:35: error: Incompatible default for argument "events" (default has type "None", argument has type "List[Any]") [assignment]
tracetools_test/case.py:319:35: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
tracetools_test/case.py:319:35: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
tracetools_test/case.py: note: In member "get_events_with_name" of class "TraceTestCase":
tracetools_test/case.py:410:35: error: Incompatible default for argument "events" (default has type "None", argument has type "List[Any]") [assignment]
tracetools_test/case.py:410:35: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
tracetools_test/case.py:410:35: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
tracetools_test/case.py: note: In member "get_events_with_procname" of class "TraceTestCase":
tracetools_test/case.py:426:35: error: Incompatible default for argument "events" (default has type "None", argument has type "List[Any]") [assignment]
tracetools_test/case.py:426:35: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
tracetools_test/case.py:426:35: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
tracetools_test/case.py: note: In member "get_events_with_field_value" of class "TraceTestCase":
tracetools_test/case.py:446:35: error: Incompatible default for argument "events" (default has type "None", argument has type "List[Any]") [assignment]
tracetools_test/case.py:446:35: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
tracetools_test/case.py:446:35: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
tracetools_test/case.py: note: In member "get_events_with_field_not_value" of class "TraceTestCase":
tracetools_test/case.py:466:35: error: Incompatible default for argument "events" (default has type "None", argument has type "List[Any]") [assignment]
tracetools_test/case.py:466:35: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
tracetools_test/case.py:466:35: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
Found 6 errors in 1 file (checked 10 source files)
See: https://github.com/ros2/ros2_tracing/actions/runs/3529381626/jobs/5920365209#step:5:26473
I have mypy version 0.942 on my 22.04 system, and so does ci.ros2.org. Looks like setup-ros
installs mypy from pip instead of apt
, so it gets a much more recent version (0.991). That explains why the failures happen in the local GitHub CI and not on ci.ros2.org or a 22.04 system configured following the official instructions. I can still fix the failures, though.
#28 fixed the legitimate mypy
issues. Since the remaining issues reported by the newer mypy
version kind of go against current practices, I'll instead change setup-ros
to use the system version of mypy
.