Skip to content

Introduce type hint for type checking #416

Description

@yck011522

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions