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

Reverts aiofiles back to _typeshed Self #9780

Closed

Conversation

erwinkinn
Copy link

@erwinkinn erwinkinn commented Feb 20, 2023

Hello,all.
This PR reverts those changes @AlexWaygood made about five days ago. After that I'd started getting this mypy error:

error: Self? has no attribute "__anext__"  [attr-defined]

A minimal code to reproduce:

async def test_():
    async with aiofiles.open(__file__) as fp:
        async for line in fp:   # <--- error here
            ...

It's quite similar to #5725, but the problem is typing_extensions.Self was not made to support an async iterator protocol.
So I've tried to rollback to an abstract type Self from _typeshed making a hot-hot fix just for now.

I'm not sure, maybe it's better to create an issue at typing_extensions for the occasion...

@Avasam
Copy link
Collaborator

Avasam commented Feb 20, 2023

Tangiantially related, FWIW, the changes in #9694 added type errors in typeshed's own code, see comment: https://github.com/python/typeshed/pull/9694/files#r1109192407 about usage of int.__new__(...) (for instance at: https://github.com/python/typeshed/blob/main/scripts/stubsabot.py#L37)

Maybe a larger discussion about typing_extensions.Self support is needed.

@erwinkinn
Copy link
Author

erwinkinn commented Feb 20, 2023

Yes, maybe u r right. I'm under my way making an issue at typing_extensions at the moment.
I have planned to reference this merge request.

@github-actions
Copy link
Contributor

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

@erwinkinn
Copy link
Author

erwinkinn commented Feb 20, 2023

Oh, thanks to bot )) However, it's still on my screen in VS Code (mypy works as a plugin).

image

As well as at my console...

image

@erwinkinn
Copy link
Author

@Avasam, sorry, I'm not sure I did understand it right. Did you mean a larger discussion about typing_extensions.Self support within the typeshed project? I thought it was about an async iterator protocol support for typing_extensions.Self :) Anyway... Discussion is needed obviously )

@AlexWaygood
Copy link
Member

This isn't an issue with typeshed, it's to do with the fact that mypy only recently added support for typing_extensions.Self. It looks like you're not using the latest version of mypy.

I can reproduce this error on mypy 0.991, but not on mypy 1.0. Mypy only added support for typing_extensions.Self in version 1.0, so I'd advise upgrading to the latest mypy if possible. If that's not possible for some reason, then your best bet is to pin your version of types-aiofiles to 22.1.0.7 or lower.

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.

3 participants