Message416853
Here's the error without dataclasses:
------
from typing import Protocol
class SomeProtocol(Protocol):
@property
def some_value(self) -> str: ...
class SomeClass(SomeProtocol):
def __init__(self, some_value):
self.some_value = some_value
if __name__ == '__main__':
a = SomeClass(some_value="value")
------
Traceback (most recent call last):
File "foo.py", line 12, in <module>
a = SomeClass(some_value="value")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "foo.py", line 9, in __init__
self.some_value = some_value
^^^^^^^^^^^^^^^
AttributeError: property 'some_value' of 'SomeClass' object has no setter
And here it is without Protocol:
--------
class SomeProperty:
@property
def some_value(self) -> str: ...
class SomeClass(SomeProperty):
def __init__(self, some_value):
self.some_value = some_value
if __name__ == '__main__':
a = SomeClass(some_value="value")
--------
Traceback (most recent call last):
File "foo.py", line 10, in <module>
a = SomeClass(some_value="value")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "foo.py", line 7, in __init__
self.some_value = some_value
^^^^^^^^^^^^^^^
AttributeError: property 'some_value' of 'SomeClass' object has no setter |
|
Date |
User |
Action |
Args |
2022-04-06 10:36:45 | eric.smith | set | recipients:
+ eric.smith, gvanrossum, JelleZijlstra, kj, AlexWaygood, Germandrummer92 |
2022-04-06 10:36:45 | eric.smith | set | messageid: <1649241405.12.0.115559104476.issue47237@roundup.psfhosted.org> |
2022-04-06 10:36:45 | eric.smith | link | issue47237 messages |
2022-04-06 10:36:45 | eric.smith | create | |
|