mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Updated documentation for import modeling differences between mypy and pyright.
This commit is contained in:
parent
1fdeadeca6
commit
414dce170e
@ -355,11 +355,16 @@ Overload resolution rules are under-specified in PEP 484. Pyright and mypy apply
|
|||||||
|
|
||||||
Pyright intentionally does not model implicit side effects of the Python import loading mechanism. In general, such side effects cannot be modeled statically because they depend on execution order. Dependency on such side effects leads to fragile code, so pyright treats these as errors. For more details, refer to [this documentation](import-statements.md).
|
Pyright intentionally does not model implicit side effects of the Python import loading mechanism. In general, such side effects cannot be modeled statically because they depend on execution order. Dependency on such side effects leads to fragile code, so pyright treats these as errors. For more details, refer to [this documentation](import-statements.md).
|
||||||
|
|
||||||
Mypy models some side effects of the import loader. If an import statement imports a submodule using a multi-part module reference, mypy assumes that all of the parent modules are also initialized and cached such they can be referenced.
|
Mypy models side effects of the import loader that are potentially unsafe.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import collections.abc
|
import http
|
||||||
collections.deque() # Pyright produces an error here because the `collections` module wasn't explicitly imported
|
|
||||||
|
def func():
|
||||||
|
import http.cookies
|
||||||
|
|
||||||
|
# The next line raises an exception at runtime
|
||||||
|
x = http.cookies # mypy allows, pyright flags as error
|
||||||
```
|
```
|
||||||
|
|
||||||
### Ellipsis in Function Body
|
### Ellipsis in Function Body
|
||||||
|
Loading…
Reference in New Issue
Block a user