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

Import suggestion should suggest collections.abc instead of typing for container types #4738

Closed
Kuba314 opened this issue Aug 18, 2023 · 8 comments
Assignees
Labels
bug Something isn't working P2

Comments

@Kuba314
Copy link

Kuba314 commented Aug 18, 2023

Container types (e.g. Iterable, Collection, ...) in the typing module are deprecated since python 3.9 (see PEP 585). These symbols should be getting imported from collections.abc instead, but the python extension keeps suggesting importing them from the typing module.

@anthonykim1 anthonykim1 transferred this issue from microsoft/vscode-python Aug 21, 2023
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Aug 21, 2023
@rchiodo
Copy link
Contributor

rchiodo commented Aug 24, 2023

Thanks for the suggestion. I suppose the downside is that these container types may eventually be removed from typing.

@rchiodo rchiodo added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Aug 24, 2023
@erictraut
Copy link
Contributor

It's unlikely these container types will ever be removed from typing. There's no significant upside to removing them (since they're just re-exports), and the downside would be huge because it would impact so much existing code.

@judej judej added the P2 label Aug 24, 2023
@judej
Copy link
Contributor

judej commented Aug 24, 2023

We need to investigate why the collections.abc is not being suggested.

@Kuba314
Copy link
Author

Kuba314 commented Aug 25, 2023

Let me know if I could help you in any way. But I assume this issue happens to everyone, because I don't think I use any non-standard configuration other than being switched to a venv created by poetry.

@Avasam
Copy link

Avasam commented Nov 30, 2023

This feels like a possible duplicate of #3318 ?
Although I'm on 2023.11.13 and collections.abc is not being recommended to me:
image

@flying-sheep
Copy link

flying-sheep commented Dec 1, 2023

It's unlikely these container types will ever be removed from typing. There's no significant upside to removing them (since they're just re-exports), and the downside would be huge because it would impact so much existing code.

Where do you take this from? Core development guidelines or personal feelings about it? Because I don’t think everyone feels that way, so if there’s nothing confirming this, I doubt it’s the case:

“Deprecated” means “will be removed at some point” in every single project I ever saw it being defined, except for “never break userspace” Linux. I can imagine there’s a handful more projects like that. Python is not one of them.

This feels like a possible duplicate of #3318?
Although I'm on 2023.11.13 and collections.abc is not being recommended to me in:

Same for me. Either this or #3318 should therefore stay open until this is actually fixed.

@Tinche
Copy link

Tinche commented Dec 11, 2023

I was just about to report this issue. I'm using Ruff in almost all of my projects, and Ruff has a rule to flag importing deprecated symbols from typing.

So now using the import quick fix is a two step operation, have VS Code generate the import, and then have Ruff fix it. ;)

@Kuba314
Copy link
Author

Kuba314 commented Dec 15, 2023

I'm on 2023.12.1 and I'm now getting both typing and collections.abc imports. I'm fine with there being both, so from my point of view this issue is now resolved.
screenshot_20231215_205354

@Kuba314 Kuba314 closed this as completed Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2
Projects
None yet
Development

No branches or pull requests

7 participants