Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce type hint for type checking #416

Open
yck011522 opened this issue Apr 19, 2024 · 0 comments
Open

Introduce type hint for type checking #416

yck011522 opened this issue Apr 19, 2024 · 0 comments
Assignees

Comments

@yck011522
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant