Pyright: TypedDict metaclasses issue

Created on 20 Oct 2020  路  6Comments  路  Source: microsoft/pyright

Describe the bug
False errors while declaring a TypedDict

To Reproduce

Consider this piece of code

from typing import TypedDict


class FooBar(TypedDict):  # <- error: The metaclass of a derived class must be a subclass of the metaclasses of all its base classes
    foo: int
    bar: float

Expected behavior
This is a valid piece of code, there should be no errors

Additional context
Pyright extensions - 1.1.80
Python - 3.8.5

addressed in next version bug

All 6 comments

The same behavior occurs with NamedTuple

This is weird, but the error no longer occurs after reloading the VS Code application.

I'm not able to repro this problem. I wonder if it has to do with an internal caching issue that is resolved once you force the language server to reload. Please report it if you see it again. Rather than reloading VS Code, try running the command "Pyright: Restart Server" within VS Code. (Display the command palette and start typing "Pyright".) If that clears the error, it will provide a good clue.

This has happened to me too after upgrading to 1.1.80 though I can't reliably reproduce it. It seems to go away after I open other files from my project which might trigger re-analysis?

I think I figured out the problem. This is a long-standing issue, not new to 1.1.80, but I can think of reasons why it might happen more frequently with the latest version.

This is addressed in pyright 1.1.81, which I just published. It will also be included in the next release of pylance.

Was this page helpful?
0 / 5 - 0 ratings