3 ms·
That's an IDE problem, with sufficently powerful code inspection, the fields can still be found. It is not the developers' job to manually add that type of info
by ReflectedImage 4y ago
That's an IDE problem, with sufficently powerful code inspection, the fields can still be found. It is not the developers' job to manually add that type of information into their source code.
Ahh so if a method on an object dynamically adds in the quack() method at runtime, does the object spontaneously change type?
- kortex 4y ago> Ahh so if a method on an object dynamically adds in the quack() method at runtime, does the object spontaneously change type? Yes, actually. This is an antipattern in the vast majority of use cases. There are far better patterns out there than just sticking a method on an object, and I detest codebases that do this sort of thing. It's almost always someone who uses the phrase "pythonic" unironically way too much, writing these sorts of things, and a nightmare to debug. There's less problem with doing something like def quackerizer(foo: Any) -> Quacker: foo.quack = lambda... return foo Still kinda odd, but at least you are doing a formal cast. > That's an IDE problem, with sufficently powerful code inspection, the fields can still be found. Ok, name one. Pycharm and vscode don't currently do it afaik. Maybe some vscode plugin, haven't used vscode much.