Skip to content

Use proper tools for typing tests #1042

Closed

Description

@sobolevn

Current typing tests are executed via pytest which calls string-based checks for mypy and pyright.

I propose using the correct way: typing.assert_type tests.
It will allow to use: per-checker ignore comments, common API that all devs can easily understand, stricter checks.

So, instead:

def check_msgpack_Decoder_decode_typed() -> None:
    dec = msgspec.msgpack.Decoder(list[int])
    b = msgspec.msgpack.encode([1, 2, 3])
    o = dec.decode(b)

    reveal_type(dec)  # assert "Decoder" in typ and "list" in typ and "int" in typ
    reveal_type(o)  # assert "list" in typ and "int" in typ

we can write:

def check_msgpack_Decoder_decode_typed() -> None:
    dec = msgspec.msgpack.Decoder(list[int])
    b = msgspec.msgpack.encode([1, 2, 3])
    o = dec.decode(b)

    assert_type(dec, msgspec.msgpack.Decoder(list[int]))
    assert_type(o, list[int])

To do so, we first need to merge #1041
After that - I will send a PR :)

Activity

  1. Siyet commented on Jun 15, 2026

    @Siyet
    Contributor

    This is done. The typing tests now use typing.assert_type instead of the old string-based reveal_type checks (#1063), with stricter checks (#1064), and run across mypy, pyright, and pyrefly (#1070), all on top of #1041. Closing as completed, thanks for driving this @sobolevn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions