Closed ngeiswei closed 2 years ago
One thing of note is that unfortunately we can’t really type check Atomese types, as the way the bindings for Python are generated results in a bunch of helper functions that do not represent types. So for example, you can’t use Python’s isinstance
to check for Atomese types, you can only type check against the generic Atom
type. For checking types you have to use the low-level method of comparing their number IDs manually.
Fixing this would require an overhaul of Python bindings, such that we generate actual Python types (i. e. classes) for each type.
Detected no activity for this issue in the last 60 days. The issue will be closed in 7 days if no further activity occurs.
More type annotations added by #32. There is a problem with using mypy though - all the existing OpenCog Python packages have to be modified to provide type annotations and a py.typed
file has to be added to signify that they provide type information.
Detected no activity for this issue in the last 60 days. The issue will be closed in 7 days if no further activity occurs.
PR #34 adds type annotations for all functions and methods of
https://github.com/opencog/rocca/blob/master/rocca/agents/core.py https://github.com/opencog/rocca/blob/master/rocca/agents/utils.py
Many files still remain un-annotated.
I'm closing that issue as the core code is fairly well type-annotated.
Out-of-the-box type annotation has been introduced in Python 3.5
https://www.python.org/dev/peps/pep-0484/
and substantially improved in Python 3.9
https://www.python.org/dev/peps/pep-0585/
Already some functions have been annotated by Adrian
https://github.com/opencog/rocca/blob/45ae155aecf1de8a4702bddd97647e48fc2fcf2a/examples/cartpole.py#L110 https://github.com/opencog/rocca/blob/45ae155aecf1de8a4702bddd97647e48fc2fcf2a/rocca/envs/wrappers/utils.py#L40
It would be very good if we take the habit to annotate all of them. We could also add, alongside the test suite #25, an easy-to-run 1-liner static checker command (using mypy or such).
Let us choose light over darkness, truth over lies, type annotation over technological apocalypse.