Skip to content

gh-104504: Run mypy on cases_generator in CI (and blacken the code) #108090

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 17 commits into from
Aug 18, 2023

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Aug 17, 2023

@corona10
Copy link
Member Author

corona10 commented Aug 17, 2023

I am not typing expert, so there might be a more promising way to attach type hints for this.

@corona10
Copy link
Member Author

cc @sobolevn

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

You might also want to alter .github/dependabot.yml, so that you get automated updates for the mypy version pin in Tools/cases_generator/requirements-dev.txt. Currently it only checks to see if dependencies in Tools/clinic/ need updating:

- package-ecosystem: "pip"
directory: "/Tools/clinic/"
schedule:
interval: "monthly"
labels:
- "skip issue"
- "skip news"

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Thanks so much for doing this!

@corona10 corona10 requested review from gvanrossum and hugovk August 18, 2023 00:30
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

(Please don't git push -f -- it makes the GitHub review reset so I can't do "changes since last review".)

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
Copy link
Member

Choose a reason for hiding this comment

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

Are there constraints on x? The cases generator uses match/case so it's got to be at least Python 3.10.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's use 3.11. We need dog fooding

Copy link
Member

Choose a reason for hiding this comment

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

3.x is "the latest stable version of Python":

https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#specifying-a-python-version

That's 3.11 now, and will be 3.12 shortly after its release.

So 3.x would be fine to minimise churn on this line (for next time).

Copy link
Member Author

Choose a reason for hiding this comment

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

So 3.x would be fine to minimise churn on this line (for next time).

Good!

Comment on lines 186 to 184
if popped is None and pushed is None:
popped, pushed = target_popped, target_pushed
else:
assert popped == target_popped
assert pushed == target_pushed
popped, pushed = target_popped, target_pushed
Copy link
Member

Choose a reason for hiding this comment

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

Those asserts need to stay -- per the comment on line 174-175, we're checking here that all targets of the pseudo have the same effects.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Thanks for taking black out.

@corona10 corona10 requested a review from gvanrossum August 18, 2023 02:44
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

LGTM. Don't worry about the origin of the Iterator type.

@corona10
Copy link
Member Author

corona10 commented Aug 18, 2023

Waiting comments of @AlexWaygood @hugovk before merging :)

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: You could actually use Argument Clinic to generate the Python code for the keywords. (Argument Clinic supports Python files.) I'm not suggesting you do it for this PR, though; just a thought :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Wow, Can I read the relevant documentation?

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! :D

@AlexWaygood AlexWaygood changed the title gh-104504: Run mypy on cases_generator gh-104504: Run mypy on cases_generator in CI (and blacken the code) Aug 18, 2023
@corona10 corona10 merged commit 28cab71 into python:main Aug 18, 2023
@corona10 corona10 deleted the gh-104504 branch August 18, 2023 13:42
@gvanrossum
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

6 participants