Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion canopen/lss.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self) -> None:
self.network: canopen.network.Network = canopen.network._UNINITIALIZED_NETWORK
self._node_id = 0
self._data = None
self.responses = queue.Queue()
self.responses: queue.Queue[bytes] = queue.Queue()

def send_switch_state_global(self, mode):
"""switch mode to CONFIGURATION_STATE or WAITING_STATE
Expand Down
9 changes: 5 additions & 4 deletions canopen/node/local.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
from collections.abc import Callable
from typing import Union

import canopen.network
Expand All @@ -26,8 +27,8 @@ def __init__(
super(LocalNode, self).__init__(node_id, object_dictionary)

self.data_store: dict[int, dict[int, bytes]] = {}
self._read_callbacks = []
self._write_callbacks = []
self._read_callbacks: list[Callable] = []
self._write_callbacks: list[Callable] = []

self.sdo = SdoServer(0x600 + self.id, 0x580 + self.id, self)
self.tpdo = TPDO(self)
Expand Down Expand Up @@ -62,10 +63,10 @@ def remove_network(self) -> None:
self.nmt.network = canopen.network._UNINITIALIZED_NETWORK
self.emcy.network = canopen.network._UNINITIALIZED_NETWORK

def add_read_callback(self, callback):
def add_read_callback(self, callback: Callable) -> None:
self._read_callbacks.append(callback)

def add_write_callback(self, callback):
def add_write_callback(self, callback: Callable) -> None:
self._write_callbacks.append(callback)

def get_data(
Expand Down
2 changes: 1 addition & 1 deletion canopen/node/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(
#: Enable WORKAROUND for reversed PDO mapping entries
self.curtis_hack = False

self.sdo_channels = []
self.sdo_channels: list[SdoClient] = []
self.sdo = self.add_sdo(0x600 + self.id, 0x580 + self.id)
self.tpdo = TPDO(self)
self.rpdo = RPDO(self)
Expand Down
14 changes: 7 additions & 7 deletions canopen/objectdictionary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def __init__(self, name: str, index: int):
self.name = name
#: Storage location of index
self.storage_location = None
self.subindices = {}
self.names = {}
self.subindices: dict[int, ODVariable] = {}
self.names: dict[str, ODVariable] = {}

def __repr__(self) -> str:
return f"<{type(self).__qualname__} {self.name!r} at {pretty_index(self.index)}>"
Expand Down Expand Up @@ -266,8 +266,8 @@ def __init__(self, name: str, index: int):
self.name = name
#: Storage location of index
self.storage_location = None
self.subindices = {}
self.names = {}
self.subindices: dict[int, ODVariable] = {}
self.names: dict[str, ODVariable] = {}

def __repr__(self) -> str:
return f"<{type(self).__qualname__} {self.name!r} at {pretty_index(self.index)}>"
Expand Down Expand Up @@ -413,7 +413,7 @@ def add_value_description(self, value: int, descr: str) -> None:
"""
self.value_descriptions[value] = descr

def add_bit_definition(self, name: str, bits: List[int]) -> None:
def add_bit_definition(self, name: str, bits: list[int]) -> None:
"""Associate bit(s) with a string description.

:param name: Name of bit(s)
Expand Down Expand Up @@ -508,7 +508,7 @@ def encode_desc(self, desc: str) -> int:
raise ValueError(
f"No value corresponds to '{desc}'. Valid values are: {valid_values}")

def decode_bits(self, value: int, bits: List[int]) -> int:
def decode_bits(self, value: int, bits: list[int]) -> int:
try:
bits = self.bit_definitions[bits]
except (TypeError, KeyError):
Expand All @@ -518,7 +518,7 @@ def decode_bits(self, value: int, bits: List[int]) -> int:
mask |= 1 << bit
return (value & mask) >> min(bits)

def encode_bits(self, original_value: int, bits: List[int], bit_value: int):
def encode_bits(self, original_value: int, bits: list[int], bit_value: int):
try:
bits = self.bit_definitions[bits]
except (TypeError, KeyError):
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ exclude = [
"^test*",
"^setup.py*",
]

[[tool.mypy.overrides]]
module = ["canmatrix.*"]
ignore_missing_imports = true
Comment thread
bizfsc marked this conversation as resolved.
Loading