You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am learning to use the attrs package and I have two questions to ask:
When using 'converter' to modify the input type when creating a property, it will cause IDE to make an error in judging the input type. For example, I originally wanted this input to be int, but it prompted me that it should be str. Is there any good way to solve this problem?
When using the class xxxx to create traditional classes, it is common to add instantiation comments in the __init__ method. Now, with attrs, the instantiation process no longer has parameter prompts. Is there any other good way to solve the problem of document prompts during instantiation besides adding comments directly to the class?
importattrs@attrs.defineclassCom:
""" Initialize Com2 instance. :param code: Code of the Com2 instance. """code: str=attrs.field(converter=str)
classCom2:
def__init__(self, code: int):
""" Initialize Com2 instance. :param code: Code of the Com2 instance. """self.code: str=str(code)
if__name__=='__main__':
com=Com(code=1)
com2=Com2(code=2)
I am learning to use the
attrspackage and I have two questions to ask:int, but it prompted me that it should bestr. Is there any good way to solve this problem?class xxxxto create traditional classes, it is common to add instantiation comments in the__init__method. Now, with attrs, the instantiation process no longer has parameter prompts. Is there any other good way to solve the problem of document prompts during instantiation besides adding comments directly to the class?