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 — Mypyc ignores custom `__new__` without warning · Issue #16012 · python/mypy Closed Labels bugmypy got something wrong DescriptionMypyc apprently ignores custom Example code (see #1020 (comment)): from __future__ import annotations class Add: l: IntLike r: IntLike def __new__(cls, l: IntLike, r: IntLike) -> IntLike: # type: ignore[misc] print(f'running __new__ with {l} and {r}') return ( l if r == 0 else r if l == 0 else super().__new__(cls) ) def __init__(self, l: IntLike, r: IntLike): self.l = l self.r = r def __repr__(self) -> str: return f'({self.l} + {self.r})' def __add__(self, other: IntLike) -> IntLike: return Add(self, other) IntLike = int | Add Code for running: print(f'{Add(1, 5)=}') print(f'{Add(0, 5)=}') print(f'{Add(1, 0)=}') Running this interpreted gives: Running compiled: The interpreted and compiled behaviors are different, which is bad. Reacted by Guy Wilson 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. |