Skip to content

TYP: add mypy defaults to pyproject.toml #43751

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

Merged
merged 2 commits into from
Sep 26, 2021

Conversation

simonjayhawkins
Copy link
Member

may make it easier for contributors to experiment with enabling mypy strictness flags

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Sep 26, 2021
@simonjayhawkins simonjayhawkins added this to the 1.4 milestone Sep 26, 2021
Copy link
Member

@twoertwein twoertwein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very useful!

Maybe add a todo(?) comment after lines that disable strict(er) behavior:
disallow_incomplete_defs = false # TODO

@simonjayhawkins
Copy link
Member Author

When we did check_untyped_defs we created an exclude list.

IIRC it takes some maintenance to have an exclude list with more than one flag as IIRC later configs override earlier ones.

Since none of the remaining flags are as important (except maybe the imports resolving to Any now that we have stubs for the cython code) as check_untyped_defs, we have not yet enabled any other flags.

We probably also still have a few "fix later" ignores from enabling check_untyped_defs globally to deal with.

for the untyped decorators, if #43744 solves the @cache_readonly issue, then probably only numba stubs for the numba.jit decorator is needed on that one.

In the past we also discussed using the module level comment syntax to make mypy checking more strict, but IIRC there was preference to keep all mypy config in the global config file.

So if that is still the case, I find implementing a level system like https://github.com/numba/numba/pull/6222/files an interesting alternative. How would something like that fit with pyright type checking.

@twoertwein
Copy link
Member

In the past we also discussed using the module level comment syntax to make mypy checking more strict, but IIRC there was preference to keep all mypy config in the global config file.

Pyright supports comments in files https://github.com/microsoft/pyright/blob/main/docs/comments.md

So if that is still the case, I find implementing a level system like https://github.com/numba/numba/pull/6222/files an interesting alternative. How would something like that fit with pyright type checking.

I don't think pyright supports this microsoft/pyright#953

If we enable decorator checking in both mypy and pyright, we could use ignore statements for the numba functions.

@jreback jreback merged commit d09e3c8 into pandas-dev:master Sep 26, 2021
@simonjayhawkins simonjayhawkins deleted the mypy-config branch September 26, 2021 15:10
@simonjayhawkins
Copy link
Member Author

In the past we also discussed using the module level comment syntax to make mypy checking more strict, but IIRC there was preference to keep all mypy config in the global config file.

Pyright supports comments in files https://github.com/microsoft/pyright/blob/main/docs/comments.md

The ability in pyright to add # pyright: strict and then exclude some checks with say # pyright: strict, reportPrivateUsage=false at first glance seems to be easier to maintain and grok than the equivalent mypy syntax of enabling individual checks

In light of this, and it would be good to start to lock down some strictness, I would be happy to see comments added to modules for pyright now that we have pyright checking on CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants