Replies: 1 comment
-
|
Because I remove the init from the template (to do important things in it in the parent class), I exposed this ini_attributes method. This is only there for the python typing tool to infer the type of your internal attributes and ease the development. The drawback is that this attributes are then declared outside of init. But no worry as ini_attributes is called right after init so you're sure your attributes will be declared with their defaults values. About the None stuff you should try: and it won't complain... but that's not really needed |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have a small question about best practice regarding the ini_attributes method of all plugins, I don't really understand how to use it. As an example, let's say my plugin class has an attribute which is a numpy array:
But if I do it like that, I get the pycharm warning "
Instance attribute background defined outside __init__" when I actually assign a value to it later.So I also thought of assigning it to None initially :
self.background: np.ndarray = NoneBut then we get the warning "
Expected type 'ndarray', got 'None' instead". And ifself.background = np.empty(0)then we get "
Instance attribute background defined outside __init__"None of this is super important, but it got me wondering why we use an ini_attribute method instead of initializing things in the
__init__!Beta Was this translation helpful? Give feedback.
All reactions