Skip to content

pyright errors when using DoesNotExist #1274

@sirianni

Description

@sirianni

Running pyright on this code results in an error

"Type[Unknown]" is not a valid exception class
(variable) DoesNotExist: Type[Unknown]
    class WidgetModel(Model):
        class Meta:  # pyright: ignore[reportIncompatibleVariableOverride]
            table_name = "widgets"
            read_capacity_units = 1
            write_capacity_units = 1

        id = UnicodeAttribute(hash_key=True)
        name = UnicodeAttribute()

    WidgetModel.create_table(wait=True)

    try:
        WidgetModel.get("id")
    except WidgetModel.DoesNotExist:
        pytest.fail("WidgetModel does not exist")

Perhaps the aliasing of the type name is confusing pyright.

DoesNotExist: Type[DoesNotExist] = DoesNotExist

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