GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Generic and __new__ with returns to a subclass produces incorrect Union inference · Issue #14502 · python/mypy Closed Labels bugmypy got something wrong DescriptionBug Report There seems to be an odd interaction between Came up in a reported issue in pandas-stubs: pandas-dev/pandas-stubs#516 Might be related to both #14009 and #14061 from __future__ import annotations from typing import TypeVar, Generic, Union, overload T = TypeVar("T", int, str) class Series(Generic[T]): @overload def __new__(cls, dtype: int) -> IntSeries: ... @overload def __new__(cls, dtype: type[T]) -> Series[T]: ... @overload def __new__(cls, dtype=...) -> Series: ... def __new__(cls, dtype=...) -> Series: cls.dtype = dtype return object.__new__(cls) ... class IntSeries(Series[int]): ... class Index: @overload def __new__(cls, dtype: int) -> IntIndex: ... @overload def __new__(cls, dtype=...) -> Index: ... def __new__(cls, dtype=...) -> Index: cls.dtype = dtype return object.__new__(cls) class IntIndex(Index): ... def foo(x: Union[Series, int, Index]): if isinstance(x, (Series, Index)): reveal_type(x) else: reveal_type(x) Expected Behavior pyright handles this correctly Actual Behavior Your Environment
Activity
MetadataMetadataAssigneesLabelsbugmypy got something wrong ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |