Skip to content

Commit

Permalink
Hotfix: Fixed #1546: Unstable (non-idempotent) behavior with certain …
Browse files Browse the repository at this point in the history
…src trees.
  • Loading branch information
timothycrosley committed Oct 8, 2020
1 parent 9ed3c03 commit 9c0ff49
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,9 @@ Changelog
NOTE: isort follows the [semver](https://semver.org/) versioning standard.
Find out more about isort's release policy [here](https://pycqa.github.io/isort/docs/major_releases/release_policy/).

### 5.6.1 [Hotfix] October 8, 2020
- Fixed #1546: Unstable (non-idempotent) behavior with certain src trees.

### 5.6.0 October 7, 2020
- Implemented #1433: Provide helpful feedback in case a custom config file is specified without a configuration.
- Implemented #1494: Default to sorting imports within `.pxd` files.
Expand Down
2 changes: 1 addition & 1 deletion isort/_version.py
@@ -1 +1 @@
__version__ = "5.6.0"
__version__ = "5.6.1"
5 changes: 4 additions & 1 deletion isort/place.py
Expand Up @@ -117,7 +117,10 @@ def _is_namespace_package(path: Path, src_extensions: FrozenSet[str]) -> bool:
init_file = path / "__init__.py"
if not init_file.exists():
filenames = [
filename for filename in path.iterdir() if filename.suffix.lstrip(".") in src_extensions
filepath
for filepath in path.iterdir()
if filepath.suffix.lstrip(".") in src_extensions
or filepath.name.lower() in ("setup.cfg", "pyproject.toml")
]
if filenames:
return False
Expand Down
14 changes: 9 additions & 5 deletions isort/settings.py
Expand Up @@ -182,7 +182,7 @@ class _Config:
directory: str = ""
profile: str = ""
honor_noqa: bool = False
src_paths: FrozenSet[Path] = frozenset()
src_paths: Tuple[Path, ...] = tuple()
old_finders: bool = False
remove_redundant_aliases: bool = False
float_to_top: bool = False
Expand Down Expand Up @@ -401,11 +401,15 @@ def __init__(
path_root = Path(combined_config.get("directory", project_root)).resolve()
path_root = path_root if path_root.is_dir() else path_root.parent
if "src_paths" not in combined_config:
combined_config["src_paths"] = frozenset((path_root, path_root / "src"))
combined_config["src_paths"] = (path_root / "src", path_root)
else:
combined_config["src_paths"] = frozenset(
path_root / path for path in combined_config.get("src_paths", ())
)
src_paths: List[Path] = []
for src_path in combined_config.get("src_paths", ()):
full_path = path_root / src_path
if full_path not in src_paths:
src_paths.append(full_path)

combined_config["src_paths"] = tuple(src_paths)

if "formatter" in combined_config:
import pkg_resources
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -3,7 +3,7 @@ line-length = 100

[tool.poetry]
name = "isort"
version = "5.6.0"
version = "5.6.1"
description = "A Python utility / library to sort Python imports."
authors = ["Timothy Crosley <timothy.crosley@gmail.com>"]
license = "MIT"
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/test_projects_using_isort.py
Expand Up @@ -140,3 +140,8 @@ def test_pyramid(tmpdir):
def test_products_zopetree(tmpdir):
git_clone("https://github.com/jugmac00/Products.ZopeTree.git", tmpdir)
run_isort([str(tmpdir)])


def test_dobby(tmpdir):
git_clone("https://github.com/rocketDuck/dobby.git", tmpdir)
run_isort([str(tmpdir / "tests"), str(tmpdir / "src")])

0 comments on commit 9c0ff49

Please sign in to comment.