From 686c20fa1d88c03da87830b0f945831412eadc89 Mon Sep 17 00:00:00 2001 From: MTR Date: Thu, 18 Jul 2024 19:47:48 +0500 Subject: [PATCH] Fixed the issue and tested it --- scripts/mkstdlibs.py | 2 +- tests/unit/test_isort.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/mkstdlibs.py b/scripts/mkstdlibs.py index 9f375be2..1fadecf3 100755 --- a/scripts/mkstdlibs.py +++ b/scripts/mkstdlibs.py @@ -37,7 +37,7 @@ class FakeApp: invdata = fetch_inventory(FakeApp(), "", url) # Any modules we want to enforce across Python versions stdlib can be included in set init - modules = {"_ast", "posixpath", "ntpath", "sre_constants", "sre_parse", "sre_compile", "sre"} + modules = {"_ast", "posixpath", "ntpath", "sre_constants", "sre_parse", "sre_compile", "sre", "_collections_abc"} for module in invdata["py:module"]: root, *_ = module.split(".") if root not in ["__future__", "__main__"]: diff --git a/tests/unit/test_isort.py b/tests/unit/test_isort.py index 7b6743c7..93a4cea3 100644 --- a/tests/unit/test_isort.py +++ b/tests/unit/test_isort.py @@ -5671,3 +5671,19 @@ def test_reexport_not_last_line() -> None: meme = "rickroll" """ assert isort.code(test_input, config=Config(sort_reexports=True)) == expd_output + + +def test_collections_abc() -> None: + test_input = ( + "from typing import Iterable, Iterator, TypeVar, cast\n" + "\n" + "from _collections_abc import dict_items, dict_keys, dict_values\n" + "from python_none_objects import NoneIterable\n" + ) + expd_output = ( + "from typing import Iterable, Iterator, TypeVar, cast\n" + "from _collections_abc import dict_items, dict_keys, dict_values\n" + "\n" + "from python_none_objects import NoneIterable\n" + ) + assert isort.code(test_input) == expd_output