13
13
14
14
from tox .config .loader .ini .factor import find_envs
15
15
from tox .config .loader .memory import MemoryLoader
16
- from tox .config .loader .section import Section
17
16
18
17
from .api import Source
19
- from .ini_section import CORE , PKG_ENV_PREFIX , TEST_ENV_PREFIX , IniSection
18
+ from .toml_section import CORE , PKG_ENV_PREFIX , TEST_ENV_PREFIX , TomlSection
20
19
21
20
if TYPE_CHECKING :
22
21
from pathlib import Path
23
22
24
23
from tox .config .loader .api import OverrideMap
24
+ from tox .config .loader .section import Section
25
25
from tox .config .sets import ConfigSet
26
26
27
27
@@ -45,13 +45,13 @@ def __init__(self, path: Path, content: str | None = None) -> None:
45
45
def __repr__ (self ) -> str :
46
46
return f"{ type (self ).__name__ } (path={ self .path } )"
47
47
48
- def transform_section (self , section : Section ) -> Section : # noqa: PLR6301
49
- return IniSection (section .prefix , section .name )
48
+ def transform_section (self , section : Section ) -> Section :
49
+ return TomlSection (section .prefix , section .name )
50
50
51
51
def get_loader (self , section : Section , override_map : OverrideMap ) -> MemoryLoader | None :
52
52
# look up requested section name in the generative testenv mapping to find the real config source
53
53
for key in self ._section_mapping .get (section .name ) or []:
54
- if section .prefix is None or Section .from_key (key ).prefix == section .prefix :
54
+ if section .prefix is None or TomlSection .from_key (key ).prefix == section .prefix :
55
55
break
56
56
else :
57
57
# if no matching section/prefix is found, use the requested section key as-is (for custom prefixes)
@@ -66,14 +66,14 @@ def get_loader(self, section: Section, override_map: OverrideMap) -> MemoryLoade
66
66
67
67
def get_base_sections (self , base : list [str ], in_section : Section ) -> Iterator [Section ]: # noqa: PLR6301
68
68
for a_base in base :
69
- section = IniSection .from_key (a_base )
69
+ section = TomlSection .from_key (a_base )
70
70
yield section # the base specifier is explicit
71
71
if in_section .prefix is not None : # no prefix specified, so this could imply our own prefix
72
- yield IniSection (in_section .prefix , a_base )
72
+ yield TomlSection (in_section .prefix , a_base )
73
73
74
- def sections (self ) -> Iterator [IniSection ]:
74
+ def sections (self ) -> Iterator [Section ]:
75
75
for key in self ._raw :
76
- yield IniSection .from_key (key )
76
+ yield TomlSection .from_key (key )
77
77
78
78
def envs (self , core_config : ConfigSet ) -> Iterator [str ]:
79
79
seen = set ()
@@ -102,7 +102,7 @@ def register_factors(envs: Iterable[str]) -> None:
102
102
for section in self .sections ():
103
103
yield from self ._discover_from_section (section , known_factors )
104
104
105
- def _discover_from_section (self , section : IniSection , known_factors : set [str ]) -> Iterator [str ]:
105
+ def _discover_from_section (self , section : Section , known_factors : set [str ]) -> Iterator [str ]:
106
106
for value in self ._raw [section .key ].values ():
107
107
if isinstance (value , bool ):
108
108
# It's not a value with env definition.
@@ -114,9 +114,9 @@ def _discover_from_section(self, section: IniSection, known_factors: set[str]) -
114
114
yield env
115
115
116
116
def get_tox_env_section (self , item : str ) -> tuple [Section , list [str ], list [str ]]: # noqa: PLR6301
117
- return IniSection .test_env (item ), [TEST_ENV_PREFIX ], [PKG_ENV_PREFIX ]
117
+ return TomlSection .test_env (item ), [TEST_ENV_PREFIX ], [PKG_ENV_PREFIX ]
118
118
119
- def get_core_section (self ) -> Section :
119
+ def get_core_section (self ) -> TomlSection :
120
120
return self .CORE_SECTION
121
121
122
122
0 commit comments