diff --git a/nox/tasks.py b/nox/tasks.py index 34a09a2d..e3c611b8 100644 --- a/nox/tasks.py +++ b/nox/tasks.py @@ -187,7 +187,7 @@ def filter_manifest( # Filter by python interpreter versions. if global_config.pythons: manifest.filter_by_python_interpreter(global_config.pythons) - if not manifest: + if not manifest and not global_config.list_sessions: logger.error("Python version selection caused no sessions to be selected.") return 3 @@ -205,19 +205,22 @@ def filter_manifest( # (which is an error condition later). manifest.filter_by_keywords(global_config.keywords) - if not manifest: + if not manifest and not global_config.list_sessions: logger.error("No sessions selected after filtering by keyword.") return 3 + # If the global_config is set to an empty list, and a list was not + # requested, and no filtering was done, if ( - not global_config.keywords - and not global_config.pythons + global_config.sessions is not None and not global_config.sessions and not global_config.list_sessions - and global_config.sessions is not None + and not global_config.keywords + and not global_config.pythons ): + manifest.filter_by_name(global_config.sessions) print("No sessions selected. Please select a session with -s .\n") - _produce_listing(manifest, global_config, select=False) + _produce_listing(manifest, global_config) return 0 # Return the modified manifest. @@ -225,7 +228,7 @@ def filter_manifest( def _produce_listing( - manifest: Manifest, global_config: Namespace, *, select: bool = True + manifest: Manifest, global_config: Namespace ) -> None: # If the user just asked for a list of sessions, print that # and any docstring specified in noxfile.py and be done. This @@ -243,7 +246,7 @@ def _produce_listing( for session, selected in manifest.list_all_sessions(): output = "{marker} {color}{session}{reset}" - if selected or not select: + if selected: marker = "*" color = selected_color else: @@ -263,10 +266,9 @@ def _produce_listing( ) ) - if select: - print( - f"\nsessions marked with {selected_color}*{reset} are selected, sessions marked with {skipped_color}-{reset} are skipped." - ) + print( + f"\nsessions marked with {selected_color}*{reset} are selected, sessions marked with {skipped_color}-{reset} are skipped." + ) def honor_list_request( diff --git a/noxfile.py b/noxfile.py index a770d9fa..2e1098b3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -28,6 +28,8 @@ if shutil.which("conda"): nox.options.sessions.append("conda_tests") +nox.options.sessions = [] + def is_python_version(session, version): if not version.startswith(session.python):