Skip to content

Commit

Permalink
Do not cache configuration files
Browse files Browse the repository at this point in the history
Fixes PyCQA#1994

isort can run in long processes when used in an editor.  In that
scenario it is confusing for users when editing a configuration file
does not change isorts outcome.

Remove the caches in `settings.py` completely to re-read the
configuration on each run.

This is safe for the CLI case as we here either use the `Trie`
implementation which collects all known configuration files beforehand,
or we exactly construct one `Config` object based on the first filename,
the working dir, or the explicit `settings_path|file` settings.

Not caching is therefore more efficient for the CLI case and more
useful for the editor case.
  • Loading branch information
kaste committed Feb 8, 2023
1 parent 4e3ccb1 commit 0b0fe05
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions isort/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import subprocess # nosec: Needed for gitignore support.
import sys
from dataclasses import dataclass, field
from functools import lru_cache
from pathlib import Path
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -766,7 +765,6 @@ def _abspaths(cwd: str, values: Iterable[str]) -> Set[str]:
return paths


@lru_cache()
def _find_config(path: str) -> Tuple[str, Dict[str, Any]]:
current_directory = path
tries = 0
Expand Down Expand Up @@ -799,7 +797,6 @@ def _find_config(path: str) -> Tuple[str, Dict[str, Any]]:
return (path, {})


@lru_cache()
def find_all_configs(path: str) -> Trie:
"""
Looks for config files in the path provided and in all of its sub-directories.
Expand Down Expand Up @@ -828,7 +825,6 @@ def find_all_configs(path: str) -> Trie:
return trie_root


@lru_cache()
def _get_config_data(file_path: str, sections: Tuple[str]) -> Dict[str, Any]:
settings: Dict[str, Any] = {}

Expand Down

0 comments on commit 0b0fe05

Please sign in to comment.