Skip to content

Type inferred as Never from cyclic * import #113

@MatthewMckee4

Description

@MatthewMckee4

Summary

My reproduction is maybe not great, but there is a package klayout that contains a .pyi file with > 75,000 lines.

mkdir /tmp/test-repro
cd /tmp/test-repro
uv venv
uv pip install klayout
echo "import klayout.db as kdb

from typing_extensions import reveal_type


def _(x: kdb.LayerInfo, y: kdb.LEFDEFReaderConfiguration):
    reveal_type(x)
    reveal_type(y)
" > main.py
uv run <red-knot-bin> check main.py

This gives the following error:

error: lint:invalid-type-form: Variable of type `Never` is not allowed in a type expression
 --> /tmp/test-repro/main.py:6:10
  |
6 | def _(x: kdb.LayerInfo):
  |          ^^^^^^^^^^^^^
7 |     reveal_type(x)
  |

info: revealed-type: Revealed type
 --> /tmp/test-repro/main.py:7:5
  |
6 | def _(x: kdb.LayerInfo):
7 |     reveal_type(x)
  |     ^^^^^^^^^^^^^^ `Unknown`
  |

Found 2 diagnostics

Also to note LayerInfo is defined at line 36702 and LEFDEFReaderConfiguration at line 35628 (and LEFDEFReaderConfiguration works fine)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingimportsModule resolution, site-packages discovery, import-related diagnostics

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions