Skip to content

Fix spurious errors on builtins.open - #15161

Merged
JukkaL merged 1 commit into
python:masterfrom
hauntsaninja:core-warm
May 2, 2023
Merged

JukkaL merged 1 commit into
python:masterfrom
hauntsaninja:core-warm

Conversation

@hauntsaninja

Copy link
Copy Markdown
Collaborator

Fixes #14796

@github-actions

github-actions Bot commented May 1, 2023

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

vision (https://github.com/pytorch/vision) got 1.19x slower (34.1s -> 40.7s)
@hauntsaninja
hauntsaninja marked this pull request as ready for review May 1, 2023 05:52
@ikonst

ikonst commented May 1, 2023 •

Copy link
Copy Markdown
Contributor

Any way to test this? (preferably in a way that clarifies the value and isn't a regression test for #14796)

@hauntsaninja

Copy link
Copy Markdown
Collaborator Author

I tested manually... I think it's a little hard to write a test, like with #14088

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I verified manually that this fixes the errors. Thanks!

@JukkaL
JukkaL merged commit 66602fc into python:master May 2, 2023
@AlexWaygood

AlexWaygood commented May 2, 2023 •

Copy link
Copy Markdown
Member

I think this change may have introduced a regression. If I run mypy on typeshed's stdlib stubs, it now reports that Module "typing_extensions" has no attribute "LiteralString".

The specific commands I ran were:

  1. Checkout 66602fc in my local clone of mypy.
  2. Activate a virtual environment with an editable install of mypy pointing to my clone.
  3. cd into my local clone of typeshed.
  4. Run python tests/mypy_test.py -p3.11 stdlib.

The results of the last command are:

stdlib\builtins.pyi:57: error: Module "typing_extensions" has no attribute "LiteralString"  [attr-defined]
stdlib\builtins.pyi:453: error: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader  [misc]
stdlib\builtins.pyi:583: error: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader  [misc]


--- exit status 1, 546 files checked ---

These errors cannot be reproduced if I run typeshed's mypy_test.py script using mypy @ b5107a9.

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

Labels

None yet

4 participants