holoviz / param

Param: Make your Python code clearer and more reliable by declaring Parameters
https://param.holoviz.org
BSD 3-Clause "New" or "Revised" License
412 stars 69 forks source link

Ensure operations that are unsafe during instance initialization raise errors #834

Closed philippjfr closed 9 months ago

philippjfr commented 9 months ago

We are finding that some users do not correctly call super().__init__() at all or perform actions that are not safe before they call it. To guide more users to the correct behavior and avoid undefined/weird behavior this PR adds some validations and errors to certain methods on the .param namespace.

maximlt commented 9 months ago

I quickly tried that and found a few places where we run __getitem__ before the class is initialized:

That suggests that it'd be worth it but would break too much code, it's likely we need to go through a deprecation period.