compas-dev / compas-dev/compas_fab
Introduce type hint for type checking
- Dominant language
- Python
- Stars
- 137
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Description
# Feature Request
As a [developer / user], I want [auto type checking] so that [coding is easier].
## Details
I intend to add type hint to functions in a IronPython / Py2 compatible style as described in this very old file. Yes Py2 is old. But unfortunately to make things compatible, it is what it is.
https://github.com/Sumindar/mypy/blob/95ab92015853fbdd3c83b081c470df92e8ca95c4/docs/source/cheat_sheet.rst
The main idea is to add a `# type: ` line immediately before docstring.
```
@property
def attached_tools(self):
# type: () -> dict[str, Tool]
"""Maps planning group to the tool attached to it."""
return self._attached_tools
```
I have been using this style for a while in my own repo. IronPython does not complain, Sphinx does not complain, PyLance in VS code grabs the type hint perfectly and enables certain autocomplete. I believe CoPilot uses this info too to make better suggestions.
I will probably start with the main classes like Robot and Tool.
Contributor guide
Assessment
This issue has not been assessed yet.