Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache env config #3268

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/3238.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue with not expanding placeholders like ``{envtmpdir}`` by :user:`bennyrowland`.
20 changes: 12 additions & 8 deletions src/tox/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__( # noqa: PLR0913

self._src = config_source
self._key_to_conf_set: dict[tuple[str, str, str], ConfigSet] = OrderedDict()
self._key_to_env_conf: dict[str, EnvConfigSet] = {}
self._core_set: CoreConfigSet | None = None
self.memory_seed_loaders: defaultdict[str, list[MemoryLoader]] = defaultdict(list)

Expand Down Expand Up @@ -159,18 +160,21 @@ def get_env(
:param loaders: loaders to use for this configuration (only used for creation)
:return: the tox environments config
"""
section, base_test, base_pkg = self._src.get_tox_env_section(item)
return self.get_section_config(
section,
base=base_pkg if package else base_test,
of_type=EnvConfigSet,
for_env=item,
loaders=loaders,
)
if item not in self._key_to_env_conf:
section, base_test, base_pkg = self._src.get_tox_env_section(item)
self._key_to_env_conf[item] = self.get_section_config(
section,
base=base_pkg if package else base_test,
of_type=EnvConfigSet,
for_env=item,
loaders=loaders,
)
return self._key_to_env_conf[item]

def clear_env(self, name: str) -> None:
section, _, __ = self._src.get_tox_env_section(name)
self._key_to_conf_set = {k: v for k, v in self._key_to_conf_set.items() if k[0] == section.key and k[1] == name}
gaborbernat marked this conversation as resolved.
Show resolved Hide resolved
self._key_to_env_conf.pop(name)


___all__ = [
Expand Down