Warum verengt MyPy IssubClass -Typ nur an "Typ" -Anstanzen?Python

Python-Programme
Anonymous
 Warum verengt MyPy IssubClass -Typ nur an "Typ" -Anstanzen?

Post by Anonymous »

Code-Snippet: < /p>

Code: Select all

from typing import Any

class MyClass:
pass

def f(o: Any) -> None:
if isinstance(o, type) and issubclass(o, MyClass):
reveal_type(o)  # Revealed type is "Type[MyClass]"

if issubclass(o, MyClass):
reveal_type(o)  # Revealed type is "Any"
Ist es ein Fehler in MyPy oder gibt es einen Grund, warum das zweite Beispiel nicht erwartet wird?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post