Skip to content

Add a stricter config pass for pyright #5612

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 3 commits into from
Jun 10, 2021
Merged

Conversation

jakebailey
Copy link
Contributor

Fixes #5607.

This adds a second stricter pyright config and runs it first in CI. I've added an example command to the contributing file as well (the test script just passes through its args).

Also bumps pyright, since that hasn't been done in a while.

@erictraut @srittau

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thank you!

(.venv3)$ python3 tests/pyright_test.py stdlib/sys.pyi # Check one file
(.venv3)$ python3 tests/pyright_test.py # Check all files
(.venv3)$ python3 tests/pyright_test.py stdlib/sys.pyi # Check one file
(.venv3)$ python3 tests/pyright_test.py -p pyrightconfig.stricter.json # Check with the stricter config.
Copy link
Member

Choose a reason for hiding this comment

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

We should document somewhere (not necessarily here) what the "stricter config" is and why it exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where would you suggest? I can leave a comment at the top of the stricter config, or put it somewhere else.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of checking a single file?

tests/README.md seems like a good location to document this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be useful; I didn't add this instruction though (it was already there).

I'll stick something in that readme.

version: ${{ env.PYRIGHT_VERSION }}
python-platform: ${{ matrix.python-platform }}
python-version: ${{ matrix.python-version }}
no-comments: ${{ matrix.python-version != '3.9' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should make only one of the strict and the lenient run generate comments?

Copy link
Contributor Author

@jakebailey jakebailey Jun 10, 2021

Choose a reason for hiding this comment

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

If the first one fails, then it will leave comments and the next step will not run. If the first one passes, then it won't leave any comments and the second one will continue as normal. There shouldn't end up being any duplication.

"typeshedPath": ".",
"include": [
"stdlib",
// Modules that pass this stricter mode.
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be preferable to exclude the modules that don't pass the strict checks? That way, there's added incentive to remove them from the exclude list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can do it that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flipped it; now it's like the old config.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think opt-out is a good idea, at least for third-party packages. I predict that this will cause CI to fail for most new packages. But let's wait and see. We can always flip this back later if it indeed turns out to be a common problem.

@srittau srittau merged commit c4dc935 into python:master Jun 10, 2021
@srittau
Copy link
Collaborator

srittau commented Jun 10, 2021

Thanks! I think this is the best of both worlds: Preventing regression of already "complete" stubs and ensuring a higher quality of incomplete stubs (by running pyright against all stubs, including its very useful warnings).

@jakebailey jakebailey deleted the pyright-rerun branch June 10, 2021 18:14
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

Successfully merging this pull request may close these issues.

Run pyright with stricter options for "known-good" stubs
4 participants