-
Notifications
You must be signed in to change notification settings - Fork 220
Closed
Labels
Description
I have been using pyright for type checking of my project using canopen in preference top mypy as it seems to be the default in VS Code. As part of upgrading to 2.3.0 I found it reporting canopen.Network() as a private symbol.
I have been able to distill a minimal example of the problem using the example code from the readme and the following environment:
virtualenv venv
. venv/bin/activate
pip install canopen pyright
Running pyright then yields a lot of errors:
$ pyright
/tmp/pytest/canopen-example.py
/tmp/pytest/canopen-example.py:4:19 - error: "Network" is not exported from module "canopen" (reportPrivateImportUsage)
/tmp/pytest/canopen-example.py:7:16 - error: "RemoteNode" is not exported from module "canopen" (reportPrivateImportUsage)
/tmp/pytest/canopen-example.py:22:52 - error: Cannot access attribute "raw" for class "SdoArray"
Attribute "raw" is unknown (reportAttributeAccessIssue)
/tmp/pytest/canopen-example.py:22:52 - error: Cannot access attribute "raw" for class "SdoRecord"
Attribute "raw" is unknown (reportAttributeAccessIssue)
/tmp/pytest/canopen-example.py:23:13 - error: "__getitem__" method not defined on type "SdoVariable" (reportIndexIssue)
/tmp/pytest/canopen-example.py:26:37 - error: Cannot assign to attribute "raw" for class "SdoArray"
Attribute "raw" is unknown (reportAttributeAccessIssue)
/tmp/pytest/canopen-example.py:26:37 - error: Cannot assign to attribute "raw" for class "SdoRecord"
Attribute "raw" is unknown (reportAttributeAccessIssue)
/tmp/pytest/canopen-example.py:51:45 - error: Cannot access attribute "raw" for class "PdoMap"
Attribute "raw" is unknown (reportAttributeAccessIssue)
8 errors, 0 warnings, 0 informations
It seems that https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface describes the rules for module imports.