Why isn't my type checker (Pyright) complaining about a clear type violation?
13:28 04 Sep 2026

Why isn't Pyright complaining about this? msg: Any is not a Message. (Pylance 2026.3.1)

import asyncio
from dataclasses import dataclass
import json

@dataclass(frozen=True, slots=True)
class Message:
    sender: str
    msg_type: str

class MessageHandler:

    _messages: asyncio.Queue[Message]

    def __init__(self) -> None:
        self._messages = asyncio.Queue()

    async def put(self, msg: Message) -> None:
        await self._messages.put(msg)

async def main():
    handler = MessageHandler()
    msg = json.loads(b'1010')
    await handler.put(msg) # why is there no error here? msg is not a Message

asyncio.run(main())
python typechecking pyright