The class properties declared at lines 23 to 25 are useless and may deceptively cause bugs, so need deleting.
I've made this mistake too, which made hard to figure out, mistakenly using class properties, bugs!
All the object self properties are public, which makes them too easy to externally modify! All of them need to be made private, with some exposed read-only via @property self methods.
A destroy self method should be added, to at least set self.__keeping_object to None, for compulsory use by the PooledObjectFactorydestroy self method, to sabotage reuse of a Pond dereferenced PoolObject. The pooled_object, is del(eted) at line 213 in pond_class.py, which should be enough, so I removed my extra code for this.
No object function can directly refer to its class name, so has to use 'class-name' or preferably Self, from from typing import Self.
PyCharm informed me of this. I think it's because the class doesn't exist yet in the namespace!
A validation Callable probably need to be injected transiently to allow validation of the object, to avoid exposing it to potential misuse via a @property self method for it.
Therefore, lines 19 to 37 of pooled_object.py should probably be replaced by:
The above was typed in a separate file in PyCharm (Community Edition), so should be fully valid code.
I've written my own Generics typed sub-class/wrapper classes for the key Pond classes, which I may put somewhere on my GitHub account, after I've proved that they work well. When I do, I may update you.
The class properties declared at lines 23 to 25 are useless and may deceptively cause bugs, so need deleting.
All the object self properties are public, which makes them too easy to externally modify! All of them need to be made private, with some exposed read-only via
@property
self methods.AThe pooled_object, is del(eted) at line 213 in pond_class.py, which should be enough, so I removed my extra code for this.destroy
self method should be added, to at least setself.__keeping_object
to None, for compulsory use by thePooledObjectFactory
destroy
self method, to sabotage reuse of a Pond dereferencedPoolObject
.No object function can directly refer to its class name, so has to use
'class-name'
or preferablySelf
, fromfrom typing import Self
.PyCharm
informed me of this. I think it's because the class doesn't exist yet in the namespace!A validation Callable probably need to be injected transiently to allow validation of the object, to avoid exposing it to potential misuse via a @property self method for it.
Therefore, lines 19 to 37 of
pooled_object.py
should probably be replaced by:The above was typed in a separate file in
PyCharm (Community Edition)
, so should be fully valid code.I've written my own Generics typed sub-class/wrapper classes for the key Pond classes, which I may put somewhere on my GitHub account, after I've proved that they work well. When I do, I may update you.