hardbyte / hardbyte/python-can

How to access typing for different CAN bus interface types so Pylance can know which instance attributes exist?

Open
#1,880 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.6k
Forks
697
PR merge metrics
No merged PRs in 30d

Description

Currently instantiating a bus looks something like:
```python
bus: can.bus.BusABC = can.Bus(channel="can0", can_filters=[...], interface="socketcan", bitrate=250_000)
```
However, then `bus.channel` is unknown because it is not defined in `can.bus.BusABC`, but `channel` is a defined and used attributed in subclasses such as `KvaserBus` and `SocketcanBus`. Is there a more specific type that can be used, or something that exposes the `channel` argument provided when instantiating a CAN bus?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.