Skip to content

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

Merged
corona10 merged 17 commits into
python:mainfrom
corona10:gh-104504
Aug 18, 2023
Merged

gh-104504: Run mypy on cases_generator in CI (and blacken the code)#108090
corona10 merged 17 commits into
python:mainfrom
corona10:gh-104504

Conversation

@corona10

@corona10corona10 commented Aug 17, 2023

Copy link
Copy Markdown
Member

@corona10

corona10 commented Aug 17, 2023

Copy link
Copy Markdown
MemberAuthor

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

Comment threadTools/cases_generator/generate_cases.py
Comment threadTools/cases_generator/analysis.py
@corona10

Copy link
Copy Markdown
MemberAuthor

cc @sobolevn

Comment threadTools/cases_generator/requirements-dev.txt Outdated
Comment threadTools/cases_generator/mypy.ini Outdated
Comment threadTools/cases_generator/requirements-dev.txt Outdated
Comment threadTools/cases_generator/formatting.py Outdated
Comment threadTools/cases_generator/generate_cases.py Outdated
Comment thread.github/workflows/mypy.yml Outdated

@AlexWaygoodAlexWaygood left a comment

Copy link
Copy Markdown
Member

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"

Comment threadTools/cases_generator/lexer.py Outdated

@gvanrossumgvanrossum left a comment

Copy link
Copy Markdown
Member

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!

Comment threadTools/cases_generator/generate_cases.py Outdated
Comment thread.github/workflows/mypy.yml Outdated
Comment threadTools/cases_generator/analysis.py
Comment threadTools/cases_generator/generate_cases.py
Comment threadTools/cases_generator/lexer.py

@gvanrossumgvanrossum left a comment

Copy link
Copy Markdown
Member

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".)

Comment thread.github/workflows/lint.yml Outdated
Comment thread.github/workflows/mypy.yml Outdated
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
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.

Comment threadTools/cases_generator/formatting.py Outdated
Comment threadTools/cases_generator/generate_cases.py
Comment threadTools/cases_generator/lexer.py

@gvanrossumgvanrossum left a comment

Copy link
Copy Markdown
Member

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.

@gvanrossumgvanrossum left a comment

Copy link
Copy Markdown
Member

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

corona10 commented Aug 18, 2023

Copy link
Copy Markdown
MemberAuthor

Waiting comments of @AlexWaygood@hugovk before merging :)

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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?

Comment threadTools/cases_generator/mypy.ini Outdated
Comment threadTools/cases_generator/mypy.ini
corona10and others added 2 commits August 18, 2023 16:21
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

@AlexWaygoodAlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks! :D

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

Copy link
Copy Markdown
Member

Thanks!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@corona10@gvanrossum@hugovk@erlend-aasland@AlexWaygood@bedevere-bot