Fix pyright error when importing from distributed#6904
Conversation
|
Can one of the admins verify this patch? Admins can comment |
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 15 files ±0 15 suites ±0 6h 36m 31s ⏱️ - 9m 6s For more details on these failures, see this check. Results for commit 8c62e7c. ± Comparison against base commit 2a2c3bb. ♻️ This comment has been updated with latest results. |
jrbourbeau
left a comment
There was a problem hiding this comment.
Thanks @ianliu. We're using mypy for type checking. cc @crusaderky for thoughts
|
The paragraph you mention from PEP 484 was written before My personal interpretation is that this is extremely unreadable, and I don't think that treating .py files as stubs just because of |
I think this is unreadable as well, so I will consider opening an issue on pyright. I was also searching for another perspective, and pyright errors go away if the symbols are put in the |
|
Yes, |
|
Opened upstream ticket: python/peps#2768 |
|
I also have found this annoying. I'd prefer |
|
Sorry for the delay. I've opened this issue microsoft/pyright#3843 on pyright, and Eric responded with this link: https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface I will change the patch to include an |
|
@crusaderky I was searching the typing-sig mailing list and found this thread: https://mail.python.org/archives/list/typing-sig@python.org/thread/YLJPWECBNPD2K4TRIBRIPISNUZJCRREY/#C2ZZKEM3EESWMDUF3PYZB4ZG2L42XUZT The thread was started by Eric Traut himself, the author of Pyright, and his concern is exactly how to determine public symbols in |
Consider the following snippet of code: ```python from distributed import Client ``` When type-checking with pyright, this gives an error stating that _"Client" is not exported from module "distributed"_. This is because pyright is following PEP 484, where I extracted the following excerpt: > Modules and variables imported into the stub are not considered > exported from the stub unless the import uses the `import ... as ... form` > or the equivalent `from ... import ... as ... form` Although `distributed` is not a stub, this rule is being applied because of the `py.typed` file, according to the following document: https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface
|
Thank you |
Consider the following snippet of code:
When type-checking with pyright, this gives an error stating that "Client" is not exported from module "distributed". This is because pyright is following PEP 484, where I extracted the following excerpt:
Although
distributedis not a stub, this rule is being applied because of thepy.typedfile.Closes #6903
Where are the tests? The CONTRIBUTING.md tells me to run
py.test, but I couldn't find how.pre-commit run --all-files