python / python/mypy

(🐞) `type` doesn't meet it's own type as a protocol

Open
#17,567 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

from typing import Protocol


class Type(Protocol):
    __name__: str
    __qualname__: str
    __module__: str


a: type[object]
b: Type = object
c: Type = a  # error: Incompatible types in assignment (expression has type "type[object]", variable has type "Type")  [assignment]
a.__name__
a.__qualname__
a.__module__

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running mypy on the provided Protocol example and compare the assignment diagnostic with the successful attribute access on type[object]. Trace the type-checking path for protocol compatibility and type objects; done means the example treats type[object] consistently with the declared Type protocol without regressing related checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.