From 1046c8c50cb388e6550a93de8f5aeb053f0703e0 Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 16:20:16 +0100 Subject: [PATCH 01/17] Tiny type narrowing --- can/interfaces/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 755e8675c..bb206e72b 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -6,7 +6,7 @@ from typing import Dict, Tuple # interface_name => (module, classname) -BACKENDS: Dict[str, Tuple[str, ...]] = { +BACKENDS: Dict[str, Tuple[str, str]] = { "kvaser": ("can.interfaces.kvaser", "KvaserBus"), "socketcan": ("can.interfaces.socketcan", "SocketcanBus"), "serial": ("can.interfaces.serial.serial_can", "SerialBus"), From be29fc97070fa2ba80f5f047aa58bf08fce86aaa Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 16:28:44 +0100 Subject: [PATCH 02/17] Fix "DeprecationWarning: SelectableGroups dict interface is deprecated. Use select." Previously, the change line issued the above deprecation warning. This code fixes it. I also tested it locally. To reproduce the error before the change, simply run `python -W error -c 'import can.interfaces'`. --- can/interfaces/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 755e8675c..8f74a114c 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -35,7 +35,7 @@ if sys.version_info >= (3, 8): from importlib.metadata import entry_points - entries = entry_points().get("can.interface", ()) + entries = entry_points(group="can.interface") BACKENDS.update( {interface.name: tuple(interface.value.split(":")) for interface in entries} ) From 6cb1af1d05561ccce3e7dab03b4fb66472e6883a Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 16:37:29 +0100 Subject: [PATCH 03/17] Add required cast Apparently, this is required for mypy to accept it .... --- can/interfaces/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index bb206e72b..f686f7633 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -6,7 +6,7 @@ from typing import Dict, Tuple # interface_name => (module, classname) -BACKENDS: Dict[str, Tuple[str, str]] = { +BACKENDS: Dict[str, Tuple[str, str]] = cast(Dict[str, Tuple[str, str]], { "kvaser": ("can.interfaces.kvaser", "KvaserBus"), "socketcan": ("can.interfaces.socketcan", "SocketcanBus"), "serial": ("can.interfaces.serial.serial_can", "SerialBus"), @@ -30,7 +30,7 @@ "neousys": ("can.interfaces.neousys", "NeousysBus"), "etas": ("can.interfaces.etas", "EtasBus"), "socketcand": ("can.interfaces.socketcand", "SocketCanDaemonBus"), -} +}) if sys.version_info >= (3, 8): from importlib.metadata import entry_points From e2071431ab544a36c19f3c12b35033e87da8b68d Mon Sep 17 00:00:00 2001 From: felixdivo Date: Wed, 21 Dec 2022 15:38:08 +0000 Subject: [PATCH 04/17] Format code with black --- can/interfaces/__init__.py | 53 ++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index f686f7633..5162360b9 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -6,31 +6,34 @@ from typing import Dict, Tuple # interface_name => (module, classname) -BACKENDS: Dict[str, Tuple[str, str]] = cast(Dict[str, Tuple[str, str]], { - "kvaser": ("can.interfaces.kvaser", "KvaserBus"), - "socketcan": ("can.interfaces.socketcan", "SocketcanBus"), - "serial": ("can.interfaces.serial.serial_can", "SerialBus"), - "pcan": ("can.interfaces.pcan", "PcanBus"), - "usb2can": ("can.interfaces.usb2can", "Usb2canBus"), - "ixxat": ("can.interfaces.ixxat", "IXXATBus"), - "nican": ("can.interfaces.nican", "NicanBus"), - "iscan": ("can.interfaces.iscan", "IscanBus"), - "virtual": ("can.interfaces.virtual", "VirtualBus"), - "udp_multicast": ("can.interfaces.udp_multicast", "UdpMulticastBus"), - "neovi": ("can.interfaces.ics_neovi", "NeoViBus"), - "vector": ("can.interfaces.vector", "VectorBus"), - "slcan": ("can.interfaces.slcan", "slcanBus"), - "robotell": ("can.interfaces.robotell", "robotellBus"), - "canalystii": ("can.interfaces.canalystii", "CANalystIIBus"), - "systec": ("can.interfaces.systec", "UcanBus"), - "seeedstudio": ("can.interfaces.seeedstudio", "SeeedBus"), - "cantact": ("can.interfaces.cantact", "CantactBus"), - "gs_usb": ("can.interfaces.gs_usb", "GsUsbBus"), - "nixnet": ("can.interfaces.nixnet", "NiXNETcanBus"), - "neousys": ("can.interfaces.neousys", "NeousysBus"), - "etas": ("can.interfaces.etas", "EtasBus"), - "socketcand": ("can.interfaces.socketcand", "SocketCanDaemonBus"), -}) +BACKENDS: Dict[str, Tuple[str, str]] = cast( + Dict[str, Tuple[str, str]], + { + "kvaser": ("can.interfaces.kvaser", "KvaserBus"), + "socketcan": ("can.interfaces.socketcan", "SocketcanBus"), + "serial": ("can.interfaces.serial.serial_can", "SerialBus"), + "pcan": ("can.interfaces.pcan", "PcanBus"), + "usb2can": ("can.interfaces.usb2can", "Usb2canBus"), + "ixxat": ("can.interfaces.ixxat", "IXXATBus"), + "nican": ("can.interfaces.nican", "NicanBus"), + "iscan": ("can.interfaces.iscan", "IscanBus"), + "virtual": ("can.interfaces.virtual", "VirtualBus"), + "udp_multicast": ("can.interfaces.udp_multicast", "UdpMulticastBus"), + "neovi": ("can.interfaces.ics_neovi", "NeoViBus"), + "vector": ("can.interfaces.vector", "VectorBus"), + "slcan": ("can.interfaces.slcan", "slcanBus"), + "robotell": ("can.interfaces.robotell", "robotellBus"), + "canalystii": ("can.interfaces.canalystii", "CANalystIIBus"), + "systec": ("can.interfaces.systec", "UcanBus"), + "seeedstudio": ("can.interfaces.seeedstudio", "SeeedBus"), + "cantact": ("can.interfaces.cantact", "CantactBus"), + "gs_usb": ("can.interfaces.gs_usb", "GsUsbBus"), + "nixnet": ("can.interfaces.nixnet", "NiXNETcanBus"), + "neousys": ("can.interfaces.neousys", "NeousysBus"), + "etas": ("can.interfaces.etas", "EtasBus"), + "socketcand": ("can.interfaces.socketcand", "SocketCanDaemonBus"), + }, +) if sys.version_info >= (3, 8): from importlib.metadata import entry_points From 05e3283c08d0c2a1426c4a9a04c6c0fecba8eba9 Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 16:41:15 +0100 Subject: [PATCH 05/17] Restore compatibility with Python version < 3.10 --- can/interfaces/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 8f74a114c..f3a6e94cf 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -35,7 +35,8 @@ if sys.version_info >= (3, 8): from importlib.metadata import entry_points - entries = entry_points(group="can.interface") + # See https://docs.python.org/3/library/importlib.metadata.html#entry-points, "Compatibility Note". + entries = entry_points(group="can.interface") if sys.version_info >= (3, 10) else entry_points().get("can.interface", ()) BACKENDS.update( {interface.name: tuple(interface.value.split(":")) for interface in entries} ) From 6885ca41d8fcaed8a711f5773fa6d847ec6145f4 Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 16:42:43 +0100 Subject: [PATCH 06/17] Add missing import --- can/interfaces/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 5162360b9..edb58b228 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -3,7 +3,7 @@ """ import sys -from typing import Dict, Tuple +from typing import cast, Dict, Tuple # interface_name => (module, classname) BACKENDS: Dict[str, Tuple[str, str]] = cast( From 41d8c0e0d2680e9f018279d0ba87262aa17732ae Mon Sep 17 00:00:00 2001 From: felixdivo Date: Wed, 21 Dec 2022 15:46:01 +0000 Subject: [PATCH 07/17] Format code with black --- can/interfaces/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index f3a6e94cf..1f115b5ad 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -36,7 +36,11 @@ from importlib.metadata import entry_points # See https://docs.python.org/3/library/importlib.metadata.html#entry-points, "Compatibility Note". - entries = entry_points(group="can.interface") if sys.version_info >= (3, 10) else entry_points().get("can.interface", ()) + entries = ( + entry_points(group="can.interface") + if sys.version_info >= (3, 10) + else entry_points().get("can.interface", ()) + ) BACKENDS.update( {interface.name: tuple(interface.value.split(":")) for interface in entries} ) From ab58780b4b776b7738a624a407d52fe08bebb221 Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 16:55:48 +0100 Subject: [PATCH 08/17] Try to fix typing --- can/interfaces/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 1f115b5ad..093c21d81 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -3,7 +3,7 @@ """ import sys -from typing import Dict, Tuple +from typing import Dict, Iterable, Tuple # interface_name => (module, classname) BACKENDS: Dict[str, Tuple[str, ...]] = { @@ -33,13 +33,13 @@ } if sys.version_info >= (3, 8): - from importlib.metadata import entry_points + from importlib.metadata import entry_points, EntryPoint # See https://docs.python.org/3/library/importlib.metadata.html#entry-points, "Compatibility Note". - entries = ( + entries: Iterable[EntryPoint] = ( entry_points(group="can.interface") if sys.version_info >= (3, 10) - else entry_points().get("can.interface", ()) + else entry_points().get("can.interface", []) ) BACKENDS.update( {interface.name: tuple(interface.value.split(":")) for interface in entries} From 41a958d7fad9f6f76cd4e5868d34a5b7322b5487 Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:04:41 +0100 Subject: [PATCH 09/17] Update __init__.py --- can/interfaces/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index edb58b228..9e03b126c 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -40,7 +40,7 @@ entries = entry_points().get("can.interface", ()) BACKENDS.update( - {interface.name: tuple(interface.value.split(":")) for interface in entries} + {interface.name: (interface.module, interface.attr) for interface in entries} ) else: from pkg_resources import iter_entry_points From 551e1c391bbb5b4a1334bd9edc1807b693ec3dee Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:19:24 +0100 Subject: [PATCH 10/17] Try to make mypy happy --- can/interfaces/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 093c21d81..2c6973b12 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -36,7 +36,7 @@ from importlib.metadata import entry_points, EntryPoint # See https://docs.python.org/3/library/importlib.metadata.html#entry-points, "Compatibility Note". - entries: Iterable[EntryPoint] = ( + entries: Iterable[EntryPoint] = ( # type: ignore entry_points(group="can.interface") if sys.version_info >= (3, 10) else entry_points().get("can.interface", []) From f5df2733791659f2b7acd6b9ca336960e187a69a Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:29:22 +0100 Subject: [PATCH 11/17] Update __init__.py --- can/interfaces/__init__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index eec099294..f9aee6112 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -39,14 +39,15 @@ from importlib.metadata import entry_points, EntryPoint # See https://docs.python.org/3/library/importlib.metadata.html#entry-points, "Compatibility Note". - entries: Iterable[EntryPoint] = ( # type: ignore - entry_points(group="can.interface") - if sys.version_info >= (3, 10) - else entry_points().get("can.interface", []) - ) - BACKENDS.update( - {interface.name: (interface.module, interface.attr) for interface in entries} - ) + # The second variant causes a deprecation warning on Python >= 3.10. + if sys.version_info >= (3, 10): + BACKENDS.update( + {interface.name: (interface.module, interface.attr) for interface in entry_points(group="can.interface")} + ) + else: + BACKENDS.update( + {interface.name: tuple(interface.value.split(":")) for interface in entry_points().get("can.interface", [])} + ) else: from pkg_resources import iter_entry_points From 11f983aae4b4975bcdbc1a85ad077adf12f68b63 Mon Sep 17 00:00:00 2001 From: felixdivo Date: Wed, 21 Dec 2022 17:00:18 +0000 Subject: [PATCH 12/17] Format code with black --- can/interfaces/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index f9aee6112..626a85f8b 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -42,11 +42,17 @@ # The second variant causes a deprecation warning on Python >= 3.10. if sys.version_info >= (3, 10): BACKENDS.update( - {interface.name: (interface.module, interface.attr) for interface in entry_points(group="can.interface")} + { + interface.name: (interface.module, interface.attr) + for interface in entry_points(group="can.interface") + } ) else: BACKENDS.update( - {interface.name: tuple(interface.value.split(":")) for interface in entry_points().get("can.interface", [])} + { + interface.name: tuple(interface.value.split(":")) + for interface in entry_points().get("can.interface", []) + } ) else: from pkg_resources import iter_entry_points From 5a202c9d1d87273f6535a347dd683daa49aa8b22 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Wed, 21 Dec 2022 18:27:39 +0100 Subject: [PATCH 13/17] Finally fix typing --- can/interfaces/__init__.py | 58 ++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 626a85f8b..24d592abb 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -6,37 +6,34 @@ from typing import cast, Dict, Iterable, Tuple # interface_name => (module, classname) -BACKENDS: Dict[str, Tuple[str, str]] = cast( - Dict[str, Tuple[str, str]], - { - "kvaser": ("can.interfaces.kvaser", "KvaserBus"), - "socketcan": ("can.interfaces.socketcan", "SocketcanBus"), - "serial": ("can.interfaces.serial.serial_can", "SerialBus"), - "pcan": ("can.interfaces.pcan", "PcanBus"), - "usb2can": ("can.interfaces.usb2can", "Usb2canBus"), - "ixxat": ("can.interfaces.ixxat", "IXXATBus"), - "nican": ("can.interfaces.nican", "NicanBus"), - "iscan": ("can.interfaces.iscan", "IscanBus"), - "virtual": ("can.interfaces.virtual", "VirtualBus"), - "udp_multicast": ("can.interfaces.udp_multicast", "UdpMulticastBus"), - "neovi": ("can.interfaces.ics_neovi", "NeoViBus"), - "vector": ("can.interfaces.vector", "VectorBus"), - "slcan": ("can.interfaces.slcan", "slcanBus"), - "robotell": ("can.interfaces.robotell", "robotellBus"), - "canalystii": ("can.interfaces.canalystii", "CANalystIIBus"), - "systec": ("can.interfaces.systec", "UcanBus"), - "seeedstudio": ("can.interfaces.seeedstudio", "SeeedBus"), - "cantact": ("can.interfaces.cantact", "CantactBus"), - "gs_usb": ("can.interfaces.gs_usb", "GsUsbBus"), - "nixnet": ("can.interfaces.nixnet", "NiXNETcanBus"), - "neousys": ("can.interfaces.neousys", "NeousysBus"), - "etas": ("can.interfaces.etas", "EtasBus"), - "socketcand": ("can.interfaces.socketcand", "SocketCanDaemonBus"), - }, -) +BACKENDS: Dict[str, Tuple[str, str]] = { + "kvaser": ("can.interfaces.kvaser", "KvaserBus"), + "socketcan": ("can.interfaces.socketcan", "SocketcanBus"), + "serial": ("can.interfaces.serial.serial_can", "SerialBus"), + "pcan": ("can.interfaces.pcan", "PcanBus"), + "usb2can": ("can.interfaces.usb2can", "Usb2canBus"), + "ixxat": ("can.interfaces.ixxat", "IXXATBus"), + "nican": ("can.interfaces.nican", "NicanBus"), + "iscan": ("can.interfaces.iscan", "IscanBus"), + "virtual": ("can.interfaces.virtual", "VirtualBus"), + "udp_multicast": ("can.interfaces.udp_multicast", "UdpMulticastBus"), + "neovi": ("can.interfaces.ics_neovi", "NeoViBus"), + "vector": ("can.interfaces.vector", "VectorBus"), + "slcan": ("can.interfaces.slcan", "slcanBus"), + "robotell": ("can.interfaces.robotell", "robotellBus"), + "canalystii": ("can.interfaces.canalystii", "CANalystIIBus"), + "systec": ("can.interfaces.systec", "UcanBus"), + "seeedstudio": ("can.interfaces.seeedstudio", "SeeedBus"), + "cantact": ("can.interfaces.cantact", "CantactBus"), + "gs_usb": ("can.interfaces.gs_usb", "GsUsbBus"), + "nixnet": ("can.interfaces.nixnet", "NiXNETcanBus"), + "neousys": ("can.interfaces.neousys", "NeousysBus"), + "etas": ("can.interfaces.etas", "EtasBus"), + "socketcand": ("can.interfaces.socketcand", "SocketCanDaemonBus"), +} if sys.version_info >= (3, 8): - from importlib.metadata import entry_points, EntryPoint + from importlib.metadata import entry_points # See https://docs.python.org/3/library/importlib.metadata.html#entry-points, "Compatibility Note". # The second variant causes a deprecation warning on Python >= 3.10. @@ -50,7 +47,8 @@ else: BACKENDS.update( { - interface.name: tuple(interface.value.split(":")) + # This cast in wrong if interface.value is formatted badly, but we just fail later + interface.name: cast(Tuple[str, str], tuple(interface.value.split(":"))) for interface in entry_points().get("can.interface", []) } ) From 18b86bab92dd03e1f8d775e9cd5cacdad5fe2be5 Mon Sep 17 00:00:00 2001 From: Felix Divo <4403130+felixdivo@users.noreply.github.com> Date: Wed, 21 Dec 2022 18:34:28 +0100 Subject: [PATCH 14/17] Update can/interfaces/__init__.py Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> --- can/interfaces/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 24d592abb..8754666a0 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -48,7 +48,7 @@ BACKENDS.update( { # This cast in wrong if interface.value is formatted badly, but we just fail later - interface.name: cast(Tuple[str, str], tuple(interface.value.split(":"))) + interface.name: cast(Tuple[str, str], tuple(interface.value.split(":", maxsplit=1))) for interface in entry_points().get("can.interface", []) } ) From 057b67770b8b786aff886ee143f3946b6fbc092f Mon Sep 17 00:00:00 2001 From: felixdivo Date: Wed, 21 Dec 2022 17:35:06 +0000 Subject: [PATCH 15/17] Format code with black --- can/interfaces/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 8754666a0..5936819e0 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -48,7 +48,9 @@ BACKENDS.update( { # This cast in wrong if interface.value is formatted badly, but we just fail later - interface.name: cast(Tuple[str, str], tuple(interface.value.split(":", maxsplit=1))) + interface.name: cast( + Tuple[str, str], tuple(interface.value.split(":", maxsplit=1)) + ) for interface in entry_points().get("can.interface", []) } ) From e968bcbb506555349839c4e1ed299aa0211450b2 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Wed, 21 Dec 2022 18:41:09 +0100 Subject: [PATCH 16/17] Cleanup --- can/interfaces/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 5936819e0..8c7d016bc 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -3,7 +3,7 @@ """ import sys -from typing import cast, Dict, Iterable, Tuple +from typing import cast, Dict, Tuple # interface_name => (module, classname) BACKENDS: Dict[str, Tuple[str, str]] = { @@ -36,7 +36,6 @@ from importlib.metadata import entry_points # See https://docs.python.org/3/library/importlib.metadata.html#entry-points, "Compatibility Note". - # The second variant causes a deprecation warning on Python >= 3.10. if sys.version_info >= (3, 10): BACKENDS.update( { @@ -45,6 +44,7 @@ } ) else: + # The entry_points().get(...) causes a deprecation warning on Python >= 3.10. BACKENDS.update( { # This cast in wrong if interface.value is formatted badly, but we just fail later @@ -57,11 +57,10 @@ else: from pkg_resources import iter_entry_points - entries = iter_entry_points("can.interface") BACKENDS.update( { interface.name: (interface.module_name, interface.attrs[0]) - for interface in entries + for interface in iter_entry_points("can.interface") } ) From e50490c8029bda301bdbf54d28c03ed95968a5a2 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Wed, 21 Dec 2022 18:45:14 +0100 Subject: [PATCH 17/17] Cleanup --- can/interfaces/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index 8c7d016bc..3065e9bfd 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -47,7 +47,6 @@ # The entry_points().get(...) causes a deprecation warning on Python >= 3.10. BACKENDS.update( { - # This cast in wrong if interface.value is formatted badly, but we just fail later interface.name: cast( Tuple[str, str], tuple(interface.value.split(":", maxsplit=1)) )