A sort of mediator object, that could register new events/functions on the fly (using mediator as a decorator) and then those functions (or objects) would immediately become available as if they were methods of the mediator object.
Python 3 is a powerful tool - this works in code, although awkward imports are needed, so that the functions get the chance to register themselves with the mediator object.
Have PyCharm show the registered functions as methods of the mediator in auto-completions, mouse-overs etc.
The dynamically registered methods do not show up in PyCharm, even when checkbox
Collect run-time types information for code insight
is checked in
File > Settings > Build, Execution, Deployment > Python Debugger
.
PyCharm supports type hinting with python stubs as described in pep-0484. So the idea is to generate such stub file for PyCharm and see if PyCharm is able to pick it up and understand it.
PyCharm EAP kind of supports it, but it is also confused AF. In some files - syntax highlight stops working, in some other files - everything works fine.
TL;DR - It's complicated.
PyCharm seems to fully support it, although the fact that CONTROL+LCLICK
on a mediator method
takes you to the stub file, instead of an actual function is somewhat annoying.
$ uname -srvmo
Linux 3.19.0-51-generic #58~14.04.1-Ubuntu SMP Fri Feb 26 22:02:58 UTC 2016 x86_64 GNU/Linux
PyCharm PY-145.61.29
Build #PY-145.61, built on February 26, 2016
JRE: 1.8.0_76-release-b18 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
PyCharm 5.0.4
Build #PY-143.1919, built on January 28, 2016
JRE: 1.7.0_95-b00 amd64
JVM: OpenJDK 64-Bit Server VM by Oracle Corporation