We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi @ssanderson, congratulations for this package! (btw, it should be included in python's stdlib)
I'd like to tell there may be an issue when there is a default property setter.
from interface import Interface, implements, default class Person(Interface): def set_name(self, value): pass def get_name(self): pass @default @property def name(self): return self.get_name() @default @name.setter def name(self,value): self.set_name(value) class MyPerson(implements(Person)): def set_name(self, value): self._name = value def get_name(self): return self._name
The above code leads to the following
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) File [...]:9, in <module> 6 from __future__ import annotations 7 from interface import Interface, default, implements ----> 9 class MultiInputDialogInterface(Interface): 11 @default 12 @property 13 def windowtitle(self) -> str: 14 return "Multiple Input Dialog" File [...]:17, in MultiInputDialogInterface() 11 @default 12 @property 13 def windowtitle(self) -> str: 14 return "Multiple Input Dialog" 16 @default ---> 17 @windowtitle.setter 18 def windowtitle(self, title: str) -> None: 19 raise NotImplementedError 21 @default 22 def set_windowtitle(self, value:str) -> MultiInputDialogInterface: AttributeError: 'default' object has no attribute 'setter'
Is that ok or did I miss something?
The text was updated successfully, but these errors were encountered:
Well, I solved it adding the @default decorator only to te setter method.
@default
Is that the desired behaviour?
This code is running fine:
from interface import Interface, implements, default class Person(Interface): def set_name(self, value): pass def get_name(self): pass @property def name(self): print('getting name, which is:') return self.get_name() @default @name.setter def name(self,value): print('setting name to:',value) self.set_name(value) class MyPerson(implements(Person)): def set_name(self, value): self._name = value def get_name(self): return self._name p = MyPerson() p.name = 'John Doe' print(p.name)
The output is:
setting name to: John Doe getting name, which is: John Doe
Sorry, something went wrong.
No branches or pull requests
Hi @ssanderson, congratulations for this package! (btw, it should be included in python's stdlib)
I'd like to tell there may be an issue when there is a default property setter.
The above code leads to the following
Is that ok or did I miss something?
The text was updated successfully, but these errors were encountered: