Consider the following valid project with a py.typed and an __init__.py like:
from decimal import Decimal
from fractions import Fraction
from typing_extensions import TypeAliasType
Real = TypeAliasType("Real", float | Decimal | Fraction)
__all__ = ("Real",)
Because of typeshed issues, we need to run --verifytypes in combination with --ignoreexternal.
But even though this should be valid, an error is reported:
$ uv run pyright --ignoreexternal --verifytypes demo
Module name: "demo"
Package directory: "~/Workspace/pyright-verifytypes-typealiastype/demo"
Module directory: "~/Workspace/pyright-verifytypes-typealiastype/demo"
Path of py.typed file: "~/Workspace/pyright-verifytypes-typealiastype/demo/py.typed"
Public modules: 1
demo
Symbols used in public interface:
demo.Real
~/Workspace/pyright-verifytypes-typealiastype/demo/__init__.py:20:1 - error: Type is missing type annotation and could be inferred differently by type checkers
Inferred type is "Real"
Symbols exported by "demo": 2
With known type: 1
With ambiguous type: 1
With unknown type: 0
(Ignoring unknown types imported from other packages)
Other symbols referenced but not exported by "demo": 0
With known type: 0
With ambiguous type: 0
With unknown type: 0
Symbols without documentation:
Functions without docstring: 0
Functions without default param: 0
Classes without docstring: 0
Type completeness score: 50%
This error disappears if we replace the alias with a Real: TypeAlias = ... or type Real = ... on Python 3.12+.
Consider the following valid project with a
py.typed
and an__init__.py
like:Because of typeshed issues, we need to run
--verifytypes
in combination with--ignoreexternal
. But even though this should be valid, an error is reported:This error disappears if we replace the alias with a
Real: TypeAlias = ...
ortype Real = ...
on Python 3.12+.See https://github.com/jorenham/pyright-verifytypes-typealiastype for a repoduction of this issue.