FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`type[...]` objects don't support `__qualname__` · Issue #19060 · python/mypy · GitHub

Repository navigation

type[...] objects don't support __qualname__ #19060

Closed as duplicate
Closed as duplicate

Description

Bug Report, To Reproduce, & Actual Behaviour

This came about while writing a simple function to extract objects' fully-qualified names. See mypy Playground:

from typing import Protocol, Any

class SupportsQualname(Protocol):
    __qualname__: str

def f(C: SupportsQualname, /) -> str:
    return C.__qualname__

Class0: type = int
Class1: type[int] = int
Class2: type[Any] = int
Class3: type[object] = int
f(Class0)  # OK
f(Class1)  # E: Argument 1 to "f" has incompatible type "type[int]"; expected "SupportsQualname"  [arg-type]
f(Class2)  # E: Argument 1 to "f" has incompatible type "type[Any]"; expected "SupportsQualname"  [arg-type]
f(Class3)  # E: Argument 1 to "f" has incompatible type "type[object]"; expected "SupportsQualname"  [arg-type]

Expected Behavior

No errors

Your Environment

  • Mypy version used: 1.15, master
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.12, 3.13

Activity

  1. A5rocks commented on May 9, 2025

    Collaborator

    Yeah, __qualname__ exists for type since it's in typeshed, I suppose we don't use type as an instance as a fallback for TypeTypes and we should?

  2. bzoracler commented on May 9, 2025

    ContributorAuthor

    Oops, this is kind of a duplicate of #17567

  3. A5rocks commented on May 9, 2025

    Collaborator

    Good catch! It's not obviously a duplicate but close enough (and definitely the same cause) so I'll just close this.

    (also turns out I was wrong -- turns out TypeType doesn't have a fallback type!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongfalse-positivemypy gave an error on correct code

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL