From 0e5f953e5149ccfacedd7867888906006a6c5830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sun, 17 Apr 2022 15:00:14 +0200 Subject: [PATCH] group_command: improve interface for subclassing --- src/poetry/console/commands/group_command.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/poetry/console/commands/group_command.py b/src/poetry/console/commands/group_command.py index e84a5f72323..fb8e3c7cf1c 100644 --- a/src/poetry/console/commands/group_command.py +++ b/src/poetry/console/commands/group_command.py @@ -60,6 +60,15 @@ def non_optional_groups(self) -> set[str]: if not group.is_optional() } + @property + def default_groups(self) -> set[str]: + """ + The groups that are considered by the command by default. + + Can be overridden to adapt behavior. + """ + return self.non_optional_groups + @property def activated_groups(self) -> set[str]: groups = {} @@ -93,9 +102,9 @@ def activated_groups(self) -> set[str]: "" ) - return groups["only"] or self.non_optional_groups.union( - groups["with"] - ).difference(groups["without"]) + return groups["only"] or self.default_groups.union(groups["with"]).difference( + groups["without"] + ) def project_with_activated_groups_only(self) -> ProjectPackage: return self.poetry.package.with_dependency_groups(