Fix arg-type, return-value, and assignment mypy errors#651
Open
bizfsc wants to merge 1 commit intocanopen-python:masterfrom
Open
Fix arg-type, return-value, and assignment mypy errors#651bizfsc wants to merge 1 commit intocanopen-python:masterfrom
bizfsc wants to merge 1 commit intocanopen-python:masterfrom
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- nmt.py: Use bytes() instead of list[int] for send_message/send_periodic - emcy.py: Fix wait() return type to Optional[EmcyError] - network.py: Fix add_node/create_node return types and type narrowing - variable.py: Fix missing return in read(), annotate Bits.raw, add type: ignore for inherently dynamic type operations - sdo/base.py: Fix missing return in get_variable(), add type: ignore for SdoArray.__len__ - objectdictionary/__init__.py: Fix __getitem__ indexability, add missing return in get_variable(), annotate ODVariable.parent, fix decode_phys/encode_phys types, add type: ignore for dynamic encode_raw operations
7d78ff8 to
b43cf9f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
arg-type,return-value,assignment,return,index, andoperatormypy errors across the codebase.Changes
canopen/nmt.pybytes()instead oflist[int]forsend_message()andsend_periodic()calls.b''instead ofNonefor node guarding remote frame data.canopen/emcy.pywait()return type:Optional[EmcyError](wasEmcyError, but returnsNoneon timeout).canopen/network.pyadd_node()return type toUnion[RemoteNode, LocalNode](accepts both).create_node()parameter type toUnion[int, LocalNode].assert node.id is not Nonefor index safety.type: ignore[arg-type]for node construction where OD may be None.canopen/variable.pyraise ValueErrorat end ofread()to satisfy missing return.Bits.rawwith proper type.isinstancecheck forvalue_descriptionsdict access.type: ignorefor dynamically typed operations (decode_phys,decode_desc,encode_bits).canopen/sdo/base.pyreturn Noneinget_variable().type: ignore[return-value]forSdoArray.__len__().canopen/objectdictionary/__init__.py__getitem__dot-notation access withisinstancecheck for indexability.return Noneinget_variable().ODVariable.parentandODArray.parentwith proper Union types.decode_phys()return type toUnion[int, float].encode_phys()without intermediate division.type: ignoreforencode_rawstring operations and min/max comparisons.type: ignorefordest.close()andsource.namein file handling.Impact
Reduces mypy error count from 95 to 51 (standalone), and combined with PRs #647, #649, #650 will bring the count down significantly further.",
false