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

fix: minor touchups based on stricter mypy settings #1060

Merged
merged 2 commits into from Apr 2, 2022

Conversation

henryiii
Copy link
Contributor

Using some stricter (and at least one new in 0.940) setting for mypy.

@@ -30,7 +30,8 @@ repos:
rev: v1.2.5
hooks:
- id: pycln
args: [--config=pyproject.toml]
args: [--all]
stages: [manual]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving this to manual, since it's still very handy, but can get in the way.

Comment on lines -100 to -102
- id: python-check-blanket-type-ignore
stages: [manual]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In MyPy 0.940, this is now an option, and using MyPy, it not only tells you that you need an error code, it suggests the correct one! :)

@@ -96,7 +96,7 @@ def architectures(self) -> Set[Architecture]:
return self.globals.architectures


Setting = Union[Dict[str, str], List[str], str]
Setting = Union[Dict[str, str], List[str], str, int]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discovered by the unreachable check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

Comment on lines -499 to +498
if config_value is None:
if not config_value:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mayeut The original version should be impossible to reach - self.reader.get should always return strings, not None, right? If it can return None, then we need some significant fixes to the typing in other places.

Discovered by unreachability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Going to mark this draft until verified)

Copy link
Member

Choose a reason for hiding this comment

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

The original version should be impossible to reach

Seems right. Not sure why it wasn't checked like manylinux here.

Copy link
Member

Choose a reason for hiding this comment

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

There's another difference between musllinux & manylinux.
manylinux has:

if not config_value:
    # default to manylinux2014
    image = pinned_images.get("manylinux2014")
elif ....
...
assert image is not None

while musllinux has (after the change):

if not config_value:
    image = pinned_images["musllinux_1_1"]
elif ....
....

Not sure why get is used for manylinux (which is the only reason for assert image is not None). It would be nicer to use image = pinned_images["manylinux2014"] no ?

I've not been through the entire history so there might be some historic reasons for this being written this way but might not make sense anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd guess it's a historical thing, perhaps from the days that manylinux2010 was the default on some platforms and manylinux2014 on others.

It would be nicer to use image = pinned_images["manylinux2014"] no ?

Agreed.

@henryiii henryiii marked this pull request as draft March 22, 2022 22:00
Comment on lines -499 to +498
if config_value is None:
if not config_value:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd guess it's a historical thing, perhaps from the days that manylinux2010 was the default on some platforms and manylinux2014 on others.

It would be nicer to use image = pinned_images["manylinux2014"] no ?

Agreed.

@@ -96,7 +96,7 @@ def architectures(self) -> Set[Architecture]:
return self.globals.architectures


Setting = Union[Dict[str, str], List[str], str]
Setting = Union[Dict[str, str], List[str], str, int]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

@henryiii henryiii marked this pull request as ready for review April 1, 2022 17:30
@henryiii henryiii added automerge Tells https://github.com/apps/mergery to squash-merge the PR when the button is green. and removed automerge Tells https://github.com/apps/mergery to squash-merge the PR when the button is green. labels Apr 1, 2022
@henryiii
Copy link
Contributor Author

henryiii commented Apr 1, 2022

Actually, I'll leave auto merge off, so we can merge all three ready PRs in a row to reduce GHA usage.

@henryiii henryiii merged commit 7ef593c into pypa:main Apr 2, 2022
@henryiii henryiii deleted the henryiii/fix/mypyup branch April 2, 2022 02:00
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.

None yet

3 participants