Fix edge-case stubtest crashes when an instance of an enum.Flag that is not a member of that enum.Flag is used as a parameter default by AlexWaygood · Pull Request #15933 · python/mypy (original) (raw)

import sys

from typing import Any, TypeVar, Iterator

_T = TypeVar('_T')

class EnumMeta(type):

def __len__(self) -> int: pass

def __iter__(self: type[_T]) -> Iterator[_T]: pass

def __reversed__(self: type[_T]) -> Iterator[_T]: pass

def __getitem__(self: type[_T], name: str) -> _T: pass

class Enum(metaclass=EnumMeta):

def __new__(cls: type[_T], value: object) -> _T: pass

def __repr__(self) -> str: pass

def __str__(self) -> str: pass

def __format__(self, format_spec: str) -> str: pass

def __hash__(self) -> Any: pass

def __reduce_ex__(self, proto: Any) -> Any: pass

name: str

value: Any

class Flag(Enum):

def __or__(self: _T, other: _T) -> _T: pass

def __and__(self: _T, other: _T) -> _T: pass

def __xor__(self: _T, other: _T) -> _T: pass

def __invert__(self: _T) -> _T: pass

if sys.version_info >= (3, 11):

__ror__ = __or__

__rand__ = __and__

__rxor__ = __xor__