Skip to content

Bump mypy to 1.4.1 #10351

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 4 commits into from
Jun 25, 2023
Merged

Bump mypy to 1.4.1 #10351

merged 4 commits into from
Jun 25, 2023

Conversation

AlexWaygood
Copy link
Member

No description provided.

@AlexWaygood
Copy link
Member Author

AlexWaygood commented Jun 23, 2023

With the latest mypy update, this test fails... but only with --python-version 3.11 or --python-version 3.12:

i3: Iterable[str] = ["a.b"]
i4: Iterable[bytes] = [b"a.b"]
assert_type(dict(string.split(".") for string in i3), Dict[str, str])

I can reproduce this locally with mypy 1.4 installed:

typeshed>python tests/regr_test.py stdlib --platform win32 --python-version 3.7 3.8 3.9 3.10 3.11 3.12
Running mypy --platform win32 --python-version 3.7 on the standard library test cases... success
Running mypy --platform win32 --python-version 3.8 on the standard library test cases... success
Running mypy --platform win32 --python-version 3.9 on the standard library test cases... success
Running mypy --platform win32 --python-version 3.10 on the standard library test cases... success
Running mypy --platform win32 --python-version 3.11 on the standard library test cases... failure

test_cases\stdlib\builtins\check_dict.py:54: error:
Expression is of type "dict[Any, Any]", not "dict[str, str]"  [assert-type]
    assert_type(dict(string.split(".") for string in i3), Dict[str, str])
    ^

Running mypy --platform win32 --python-version 3.12 on the standard library test cases... failure

test_cases\stdlib\builtins\check_dict.py:54: error:
Expression is of type "dict[Any, Any]", not "dict[str, str]"  [assert-type]
    assert_type(dict(string.split(".") for string in i3), Dict[str, str])
    ^


Test completed with errors

Anybody have any idea why this might be?? I'm struggling to reproduce the issue in mypy playground: https://mypy-play.net/?mypy=latest&python=3.11&gist=7a359709f41eb7a8a26cc8e201dbae79

@AlexWaygood
Copy link
Member Author

I bisected using an editable install of mypy to find the mypy commit that broke this test:

66602fcde3468d7a284aa89cb280d448f454e07b is the first bad commit
commit 66602fcde3468d7a284aa89cb280d448f454e07b
Author: Shantanu <[email protected]>
Date:   Tue May 2 06:51:13 2023 -0700

    Fix spurious errors on builtins.open (#15161)

    Fixes #14796

 mypy/semanal_main.py | 1 +
 1 file changed, 1 insertion(+)

Cc. @hauntsaninja

@AlexWaygood
Copy link
Member Author

AlexWaygood commented Jun 23, 2023

Luckily this seems to be a typeshed-specific problem; most users of dict won't be affected here. The regression is only reproducible with --custom-typeshed-dir <typeshed_clone>. Here's the results I get with mypy 1.4.0 installed:

typeshed>mypy -c "reveal_type(dict(string.split('.') for string in ['a.b']))"
<string>:1: note: Revealed type is "builtins.dict[builtins.str, builtins.str]"
Success: no issues found in 1 source file

typeshed>mypy -c "reveal_type(dict(string.split('.') for string in ['a.b']))" --custom-typeshed-dir .
<string>:1: note: Revealed type is "builtins.dict[Any, Any]"
Success: no issues found in 1 source file

This is presumably because typeshed main and mypy's vendored copy of typeshed now have slightly different versions of builtins.pyi, as mypy reverts the change where we started using LiteralString in builtins whenever it does a typeshed sync. (Mypy does this due to the fact that it doesn't yet support LiteralString).

@hauntsaninja
Copy link
Collaborator

I'll revert that mypy PR :-/

@AlexWaygood AlexWaygood marked this pull request as ready for review June 25, 2023 23:35
@AlexWaygood AlexWaygood changed the title Bump mypy to 1.4.0 Bump mypy to 1.4.1 Jun 25, 2023
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Nice, thank you!

@hauntsaninja hauntsaninja merged commit 1b2e409 into python:main Jun 25, 2023
@AlexWaygood AlexWaygood deleted the mypy-1.4 branch June 25, 2023 23:45
@AlexWaygood
Copy link
Member Author

Nice, thank you!

Thank you for the 1.4.1 release!

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.

2 participants