Skip to content

reportUnknownVariableType error notification by pyright #182

@jcamatta

Description

@jcamatta

Hi

Context

I use very often static type checkers of python, like pyright.
Recently I installed this library and got the reportUnknownVariableType error.

Here is an image of notification

image

Is mainly due to the context parameter which is defined as dict only. So, this provokes the Unknown error.

Proposal

Since the context should receive a type and an instance, I suggest to create a subtype like this:

from typing import TypeVar

T = TypeVar("T")

def func(context: dict[type[T], T]) -> None:
    pass

func({int: 1}) # <- 0 error
func({str: 1}) # <- error

what do you think?


Enviroment configuration

I was using dishka-1.2.0

This was my project.toml pyright config:

[tool.pyright]
include = ["code"]
exclude = ["projects"]
pythonVersion = "3.10"
pythonPlatform = "Linux"
strict = ["**"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy