New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mypyc] property setter and deleter don't work with parameterized attributes #13231
Comments
@AlexWaygood, I narrowed the source of the problem. It isn't setters and deleters by themselves, but in conjunction with (at least) weakref (and maybe other types). |
Just tested on from __future__ import annotations
from typing import Generic, Protocol, TypeVar
T = TypeVar("T")
O = TypeVar("O", covariant=True)
class Thing(Protocol[O]):
def __call__(self) -> O: ...
class Bar(Generic[T]):
_attr: Thing[T] | None
def __init__(self) -> None:
self._attr = None
@property
def attr(self) -> T | None:
return self._attr() if self._attr is not None else None
@attr.deleter # compiles if deleter (and what it decorates) is commented out
def attr(self) -> None:
self._attr = None This raises the same exception, so I suspect the problem is actually with setting parameterized attributes? |
I'm afraid I'm only a triager here, and mypyc is one of the areas of mypy I know least about, so I'm probably not the person you want to be tagging here, I'm afraid :) |
Whom should I tag? |
97littleleaf11, ichard26 or JukkaL might be interested. (ichard26 isn't a core dev, but he's made several mypyc contributions and uses mypyc for compiling But we're all volunteers with limited free time :) |
Thanks @AlexWaygood. @JukkaL, I think I've found an issue with how mypyc processes parametrized attributes, at least in the context of decorated methods. I've been trying to understand the error trace to submit a PR resolving this issue, but I don't yet grok Mypy(s)'s internals. Hopefully this and #13304 are easily resolved issues. |
Bug Report
mypyc
fails to compile a class with aproperty
setter
anddeleter
and a weakref attribute.To Reproduce
foo.py
) a classBar
with a property that has a setter and deleter and weakref attribute.mypyc foo.py
3.e.g.
Actual Behavior
I get the following error:
This error does not occur when
setter
anddeleter
are omitted.Your Environment
mypy.ini
(and other config files): N/AThe text was updated successfully, but these errors were encountered: