diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2019-10-12 13:00:29 -0700 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2019-10-12 13:00:29 -0700 |
commit | 882484d35e4fad3542c93118fd27a3d2cd2aa6b4 (patch) | |
tree | be8f8d69acbea52ca50a11482cc214e3b6fddc2b | |
parent | 9d27466004f8675f588fedf55e549663addf5602 (diff) | |
download | isort-882484d35e4fad3542c93118fd27a3d2cd2aa6b4.tar.gz |
Fix conda integration detection of stdlib
-rw-r--r-- | isort/finders.py | 2 | ||||
-rw-r--r-- | isort/settings.py | 3 | ||||
-rw-r--r-- | test_isort.py | 1 |
3 files changed, 4 insertions, 2 deletions
diff --git a/isort/finders.py b/isort/finders.py index 410442c2..5c23389c 100644 --- a/isort/finders.py +++ b/isort/finders.py @@ -190,6 +190,8 @@ class PathFinder(BaseFinder): return self.sections.THIRDPARTY if self.virtual_env and self.virtual_env_src in prefix: return self.sections.THIRDPARTY + if os.path.normcase(prefix) == self.stdlib_lib_prefix: + return self.sections.STDLIB if self.conda_env and self.conda_env in prefix: return self.sections.THIRDPARTY if os.path.normcase(prefix).startswith(self.stdlib_lib_prefix): diff --git a/isort/settings.py b/isort/settings.py index dee036fe..5b8ea325 100644 --- a/isort/settings.py +++ b/isort/settings.py @@ -9,6 +9,7 @@ import configparser import enum import fnmatch import os +import posixpath import re import sys import warnings @@ -17,8 +18,6 @@ from functools import lru_cache from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Mapping, MutableMapping, Optional, Union -import posixpath - from .stdlibs import py3, py27 from .utils import difference, union diff --git a/test_isort.py b/test_isort.py index 7efe3ab4..337d8f0a 100644 --- a/test_isort.py +++ b/test_isort.py @@ -3017,6 +3017,7 @@ def test_path_finder(monkeypatch) -> None: posixpath.join(third_party_prefix, "example_4" + ext_suffix), posixpath.join(os.getcwd(), "example_5.py"), } + monkeypatch.setattr("isort.finders.exists_case_sensitive", lambda p: p in imaginary_paths) assert finder.find("example_1") == finder.sections.STDLIB assert finder.find("example_2") == finder.sections.THIRDPARTY |