Skip to content

Commit

Permalink
Merge sessions and tags
Browse files Browse the repository at this point in the history
  • Loading branch information
q0w committed Jan 16, 2023
1 parent 1fe4414 commit eb40061
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions nox/_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@
)


def _sessions_and_keywords_merge_func(
def _sessions_merge_func(
key: str, command_args: argparse.Namespace, noxfile_args: argparse.Namespace
) -> list[str]:
"""Only return the Noxfile value for sessions/keywords if neither sessions
or keywords are specified on the command-line.
"""Only return the Noxfile value for sessions/keywords if neither sessions,
keywords or tags are specified on the command-line.
Args:
key (str): This function is used for both the "sessions" and "keywords"
Expand All @@ -78,7 +78,11 @@ def _sessions_and_keywords_merge_func(
command-line.
noxfile_Args (_option_set.Namespace): The options specified in the
Noxfile."""
if not command_args.sessions and not command_args.keywords:
if (
not command_args.sessions
and not command_args.keywords
and not command_args.tags
):
return getattr(noxfile_args, key) # type: ignore[no-any-return]
return getattr(command_args, key) # type: ignore[no-any-return]

Expand Down Expand Up @@ -260,7 +264,7 @@ def _session_completer(
"--session",
group=options.groups["sessions"],
noxfile=True,
merge_func=functools.partial(_sessions_and_keywords_merge_func, "sessions"),
merge_func=functools.partial(_sessions_merge_func, "sessions"),
nargs="*",
default=_sessions_default,
help="Which sessions to run. By default, all sessions will run.",
Expand All @@ -282,7 +286,7 @@ def _session_completer(
"--keywords",
group=options.groups["sessions"],
noxfile=True,
merge_func=functools.partial(_sessions_and_keywords_merge_func, "keywords"),
merge_func=functools.partial(_sessions_merge_func, "keywords"),
help="Only run sessions that match the given expression.",
),
_option_set.Option(
Expand All @@ -291,6 +295,7 @@ def _session_completer(
"--tags",
group=options.groups["sessions"],
noxfile=True,
merge_func=functools.partial(_sessions_merge_func, "tags"),
nargs="*",
help="Only run sessions with the given tags.",
),
Expand Down

0 comments on commit eb40061

Please sign in to comment.