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

Add type hints #199

Open
sea-bass opened this issue Jul 9, 2024 · 2 comments
Open

Add type hints #199

sea-bass opened this issue Jul 9, 2024 · 2 comments
Labels

Comments

@sea-bass
Copy link
Owner

sea-bass commented Jul 9, 2024

I want to do this so badly! But if someone wants to help, I won't be mad.

MyPy is promising: https://mypy-lang.org/, which has pre-commit hooks at https://github.com/pre-commit/mirrors-mypy

Would like to see how this plays with the docs generation as well.

@sea-bass
Copy link
Owner Author

sea-bass commented Jul 19, 2024

I think the first order of business is to add mypy to the pre-commit check so it runs on CI:
https://github.com/pre-commit/mirrors-mypy

Unless this has a way to filter by folder, we may have to do the entire repo at once in order for CI to pass.

But if there is a way to filter this check by folder, it would be nice to break up the PRs. This is their official recommendation too:

https://mypy.readthedocs.io/en/stable/existing_code.html#start-small

I would recommend starting with a draft PR that applies this for one file, because I am interested in also seeing what it ends up looking like and how we have to modify the docstrings / docs generation so the docs look good with type annotations.

@kumar-sanjeeev
Copy link

kumar-sanjeeev commented Jul 20, 2024

There is a way to filter folders/ files/directories to exclude them from the mypy check. This can be done by enabling or using the --exclude option from the configuration file.

https://mypy.readthedocs.io/en/stable/config_file.html

I created a similar config file in the root dir and excluded the major directories in the repository from the mypy check. Now, I am able to run this file from the command-line interface like this:

mypy --config-file "CONFIG_FILE_NAME" .

This is running fine.

Now, because we want to configure mypy with pre-commit, I tried to read the config file from the pre-commit hook in the form of an argument. As of now, it is not working. I am figuring this out.

-   repo: https://github.com/pre-commit/mirrors-mypy
    rev: ''v1.10.1 " 
    hooks:
    -   id: mypy
        args: [--config-file, CONFIG_FILE_NAME]

Repository owner deleted a comment from kumar-sanjeeev Aug 15, 2024
Repository owner deleted a comment from kumar-sanjeeev Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants