Pop individual flag options from session.posargs. Returns a named tuple with the individual flag options indicated, as well the new posargs with those flags removed from the string list so that the posargs can be forwarded onto pytest. Basically if nox had an option for additional
(posargs: list[str], *args: str)
| 178 | |
| 179 | |
| 180 | def extract_opts(posargs: list[str], *args: str) -> tuple[list[str], Any]: |
| 181 | """Pop individual flag options from session.posargs. |
| 182 | |
| 183 | Returns a named tuple with the individual flag options indicated, |
| 184 | as well the new posargs with those flags removed from the string list |
| 185 | so that the posargs can be forwarded onto pytest. |
| 186 | |
| 187 | Basically if nox had an option for additional environmental flags that |
| 188 | didn't require putting them after ``--``, we wouldn't need this, but this |
| 189 | is probably more flexible. |
| 190 | |
| 191 | """ |
| 192 | underscore_args = [arg.replace("-", "_") for arg in args] |
| 193 | return_tuple = collections.namedtuple("options", underscore_args) # type: ignore # noqa: E501 |
| 194 | |
| 195 | look_for_args = {f"--{arg}": idx for idx, arg in enumerate(args)} |
| 196 | return_args = [False for arg in args] |
| 197 | |
| 198 | def extract(arg: str) -> bool: |
| 199 | if arg in look_for_args: |
| 200 | return_args[look_for_args[arg]] = True |
| 201 | return True |
| 202 | else: |
| 203 | return False |
| 204 | |
| 205 | return [arg for arg in posargs if not extract(arg)], return_tuple( |
| 206 | *return_args |
| 207 | ) |
| 208 | |
| 209 | |
| 210 | def apply_pytest_opts( |
no test coverage detected