PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.45k stars 574 forks source link

isort does not recognize _collections_abc as part of the standard library #2250

Open LLyaudet opened 5 months ago

LLyaudet commented 5 months ago

Hello,

In my repository: https://github.com/LLyaudet/python-repeatable-iterable/blob/main/src/python_repeatable_iterable/__init__.py I have the following imports:

from typing import Iterable, Iterator, TypeVar, cast
from _collections_abc import dict_items, dict_keys, dict_values

from python_none_objects import NoneIterable

But isort does not recognize that

from _collections_abc import dict_items, dict_keys, dict_values

is part of the standard library and regroup it like that:

from typing import Iterable, Iterator, TypeVar, cast

from _collections_abc import dict_items, dict_keys, dict_values
from python_none_objects import NoneIterable

Best regards, Laurent Lyaudet

devdanzin commented 1 month ago

Hello, we would like to fix this issue. Is there agreement that _collections_abc should be added to the list of standard library modules?

LLyaudet commented 1 day ago

Hello @devdanzin :), Thanks for looking at this problem. Sorry for my late answer, I have been away from my laptop for some time. There is indeed this agreement. _collections_abc is somewhat a private standard library modules, as is shown by this URL :

https://github.com/python/cpython/blob/main/Lib/_collections_abc.py

I would suggest that you add all other "private standard library modules" that are listed here: https://github.com/python/cpython/tree/main/Lib

Thank you very much, best regards, Laurent Lyaudet