Fix trivial mypy errors#647
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Do the two libraries really not ship any typing info? At least for python-can, I'm certain they do have them, but not as stubs. Oh, and please, could we try to separate a bit more, touching only related modules at a time? |
I though about this, but I decided against it, because I really tried only to fix the most trivial cases in this PR. There will be future PRs (currently working on it) which will be separated by mypy topic. |
|
Alright, it is in fact fairly straightforward. One more thing I'd stuff in there though is annotating the argument of What about the dependency typing info? canmatrix has it in the development branch, but not yet released. can is properly typed and marked as such. |
- Add mypy overrides to ignore missing imports for 'can' and 'canmatrix' - Replace List[int] with list[int] (PEP 585, supported since Python 3.9) - Add type annotations for untyped variables (var-annotated): - lss.py: Queue[bytes] - node/local.py: list[Callable] for callbacks - node/remote.py: list[SdoClient] for sdo_channels - objectdictionary/__init__.py: dict[int, ODVariable] / dict[str, ODVariable]
01429c1 to
8c6e1c6
Compare
Fix trivial mypy errors to prepare for type checking adoption.
Changes
pyproject.toml[[tool.mypy.overrides]]to ignore missing imports forcanandcanmatrix(third-party libraries without type stubs).canopen/objectdictionary/__init__.pyList[int]withlist[int](PEP 585, supported since Python 3.9).subindicesandnamesdicts inODRecordandODArray.canopen/lss.pyself.responsesasqueue.Queue[bytes].canopen/node/local.py_read_callbacksand_write_callbacksaslist[Callable].canopen/node/remote.pysdo_channelsaslist[SdoClient].Impact
Reduces mypy errors from 95 to 87 (eliminates all
import-not-found,name-defined, andvar-annotatederrors).