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

Use typing_extensions.Self in the stubs/ directory #9702

Merged
merged 8 commits into from
Feb 15, 2023

Conversation

AlexWaygood
Copy link
Member

Note that this will mean that the changed third-party packages are no longer compatible with mypy <1.0. However, we've already broken compatibility with mypy <1.0 in several third-party stubs in #9689 and #9695 ¯\_(ツ)_/¯.

I used the same script as in #9694 to create the first commit in this PR.

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member Author

I'm not sure I understand the pyright failures in the pika stubs. @erictraut are these legitimate errors being emitted by pyright here, in your opinion, or are these false positives?

@srittau
Copy link
Collaborator

srittau commented Feb 9, 2023

Note that this will mean that the changed third-party packages are no longer compatible with mypy <1.0.

We probably need to have a conversation how we can better signal type checker compatibility to our users, but for now I'm fine with breaking compatibility when a new type checker version comes out. Automatically upgrading type stub packages is dangerous in any case.

@erictraut
Copy link
Contributor

@AlexWaygood, this looks like a bug in pyright. I'll try to get it fixed by the end of the day. If this is blocking you, I could do a hot fix release, or we could wait until next Tuesday for the normal weekly release.

@AlexWaygood
Copy link
Member Author

If this is blocking you, I could do a hot fix release, or we could wait until next Tuesday for the normal weekly release.

Don't worry, I can easily revert the changes on the affected files for now. No need for a hotfix release, I don't think.

@github-actions

This comment has been minimized.

@erictraut
Copy link
Contributor

I've fixed the pyright bug. It will be included in the next weekly release (1.1.294).

@AlexWaygood
Copy link
Member Author

I've fixed the pyright bug. It will be included in the next weekly release (1.1.294).

Thank you very much!

@AlexWaygood
Copy link
Member Author

7fc50c6 of this PR can be reverted now that we've updated to the latest pyright in CI, but I don't have access to a computer right now and it doesn't seem possible to revert a commit on your phone

@github-actions

This comment has been minimized.

@srittau
Copy link
Collaborator

srittau commented Feb 15, 2023

I've reverted 7fc50c6

@github-actions
Copy link
Contributor

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

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Spot checking looks good.

@srittau srittau merged commit 7180d02 into python:main Feb 15, 2023
@AlexWaygood AlexWaygood deleted the Self-stubs branch February 15, 2023 10:56
@AlexWaygood
Copy link
Member Author

I've reverted 7fc50c6

Thank you very much!

efiop added a commit to iterative/dvc that referenced this pull request Feb 16, 2023
types-tqdm broke compatibility with mypy < 1 and looks like we will start running into other typeshed packages soon python/typeshed#9702
neiljp added a commit to neiljp/zulip-terminal that referenced this pull request Feb 16, 2023
This is necessary since fresh environment builds (including CI) appear to pull
a version of types-requests that is broken with mypy < 1.0, types-requests
being the broken-out 3rd-party package of stubs for requests, but that is still
maintained in typeshed.

This appears to be python/typeshed#9702.

The mypy version is updated to ~=1.0.0 versioning now that it has moved to a
major/minor/point versioning scheme.
neiljp added a commit to zulip/zulip-terminal that referenced this pull request Feb 16, 2023
This is necessary since fresh environment builds (including CI) appear to pull
a version of types-requests that is broken with mypy < 1.0, types-requests
being the broken-out 3rd-party package of stubs for requests, but that is still
maintained in typeshed.

This appears to be python/typeshed#9702.

The mypy version is updated to ~=1.0.0 versioning now that it has moved to a
major/minor/point versioning scheme.
tsibley added a commit to nextstrain/cli that referenced this pull request Feb 27, 2023
…py on 3.6

mypy 0.971 is the last version to support Python 3.6, so this is what
pip installs on 3.6.

types-requests 2.28.11.12 is the last version to support mypy <1.0.0,
due to changes in how the "Self" type is handled.¹  However, there's no
way to declare that in package metadata (without requiring mypy, which
is inappropriate for a typeshed package), so we have to resolve this
dependency ourselves.²

With a too-new types-requests, mypy fails on 3.6 with errors like:

    nextstrain/cli/remote/nextstrain_dot_org.py:230: error: Self? has no attribute "auth"

which we saw in CI failures.³

We'll drop support for Python 3.6 sooner than later, but for now, keep
it going.

¹ <python/typeshed@7180d02>
  <python/typeshed#9702>

² It would be possible if, for example, Python package metadata
  supported a "Conflicts" field, as many packaging systems do.

³ <https://github.com/nextstrain/cli/actions/runs/4266385449/jobs/7426841852#step:5:78>
@tsibley
Copy link

tsibley commented Feb 27, 2023

@srittau wrote:

We probably need to have a conversation how we can better signal type checker compatibility to our users, but for now I'm fine with breaking compatibility when a new type checker version comes out. Automatically upgrading type stub packages is dangerous in any case.

End user here. Better signaling would be nice. It's too bad there's no "Conflicts" field for Python package metadata, since it would be ~perfect for the third-party typeshed stub packages to declare which versions of type checkers they aren't compatible with.

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.

4 participants