Skip to content

Commit 6a73015

Browse files
worksbyfridayclaude
andcommitted
Style: remove single-letter vars, compact comments per review
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dfb55dc commit 6a73015

1 file changed

Lines changed: 12 additions & 23 deletions

File tree

src/tox/config/source/toml_pyproject.py

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,16 @@ def run_env_base(cls) -> str:
5555

5656
@property
5757
def keys(self) -> Iterable[str]:
58-
# Build keys from prefix and name components directly, rather than
59-
# splitting the joined key on SEP. This preserves dots that are part
60-
# of the name (e.g. environment name "py3.11") instead of treating
61-
# them as path separators.
62-
prefix = self._prefix
63-
name = self._name
58+
# Build keys from prefix + name directly, preserving dots in names (e.g. env "py3.11").
59+
prefix, name = self._prefix, self._name
6460
if prefix is None and not name:
6561
return []
66-
prefix_parts: list[str] = prefix.split(self.SEP) if prefix else []
67-
# Strip the global PREFIX (e.g. ("tool", "tox")) from the front
68-
if (
69-
self.PREFIX
70-
and len(prefix_parts) >= len(self.PREFIX)
71-
and tuple(prefix_parts[: len(self.PREFIX)]) == self.PREFIX
72-
):
73-
prefix_parts = prefix_parts[len(self.PREFIX) :]
74-
result = prefix_parts
62+
parts: list[str] = prefix.split(self.SEP) if prefix else []
63+
if self.PREFIX and len(parts) >= len(self.PREFIX) and tuple(parts[: len(self.PREFIX)]) == self.PREFIX:
64+
parts = parts[len(self.PREFIX) :] # strip global PREFIX (e.g. ("tool", "tox"))
7565
if name:
76-
result.append(name)
77-
return result
66+
parts.append(name)
67+
return parts
7868

7969

8070
class TomlPyProjectSection(TomlSection):
@@ -128,7 +118,7 @@ def get_loader(self, section: Section, override_map: OverrideMap) -> Loader[Any]
128118

129119
def envs(self, core_conf: CoreConfigSet) -> Iterator[str]:
130120
yield from core_conf["env_list"]
131-
yield from [i.name for i in self.sections()]
121+
yield from [section.name for section in self.sections()]
132122

133123
def sections(self) -> Iterator[Section]:
134124
for env_name in self._our_content.get(self._Section.ENV, {}):
@@ -138,11 +128,10 @@ def sections(self) -> Iterator[Section]:
138128
yield self._Section.test_env(env_name)
139129

140130
def get_base_sections(self, base: list[str], in_section: Section) -> Iterator[Section]: # noqa: ARG002
141-
core = self._Section.core_prefix()
142-
prefix = f"{core}{self._Section.SEP}" if core else ""
143-
for b in base:
144-
name = b.removeprefix(prefix)
145-
yield self._Section(prefix=core or None, name=name)
131+
core_prefix = self._Section.core_prefix()
132+
strip = f"{core_prefix}{self._Section.SEP}" if core_prefix else ""
133+
for entry in base:
134+
yield self._Section(prefix=core_prefix or None, name=entry.removeprefix(strip))
146135

147136
def get_tox_env_section(self, item: str) -> tuple[Section, list[str], list[str]]:
148137
return self._Section.test_env(item), [self._Section.run_env_base()], [self._Section.package_env_base()]

0 commit comments

Comments
 (0)