mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-09 21:28:21 +00:00
[ty] Regression test for relative import in stubs package (#18123)
## Summary Regression test for https://github.com/astral-sh/ty/issues/408
This commit is contained in:
parent
196e4befba
commit
8644c9da43
1 changed files with 30 additions and 0 deletions
|
@ -284,3 +284,33 @@ from shapes import Hexagon, Pentagon
|
||||||
reveal_type(Pentagon().sides) # revealed: int
|
reveal_type(Pentagon().sides) # revealed: int
|
||||||
reveal_type(Hexagon().area) # revealed: int | float
|
reveal_type(Hexagon().area) # revealed: int | float
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Relative import in stub package
|
||||||
|
|
||||||
|
Regression test for <https://github.com/astral-sh/ty/issues/408>
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[environment]
|
||||||
|
extra-paths = ["/packages"]
|
||||||
|
```
|
||||||
|
|
||||||
|
`/packages/yaml-stubs/__init__.pyi`:
|
||||||
|
|
||||||
|
```pyi
|
||||||
|
from .loader import *
|
||||||
|
```
|
||||||
|
|
||||||
|
`/packages/yaml-stubs/loader.pyi`:
|
||||||
|
|
||||||
|
```pyi
|
||||||
|
class YamlLoader: ...
|
||||||
|
```
|
||||||
|
|
||||||
|
`main.py`:
|
||||||
|
|
||||||
|
```py
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
# TODO: This should not be an error
|
||||||
|
yaml.YamlLoader # error: [unresolved-attribute] "Type `<module 'yaml'>` has no attribute `YamlLoader`"
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue