Skip to content

Commit

Permalink
group_command: improve interface for subclassing
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering authored and abn committed Apr 25, 2022
1 parent 6beef61 commit 0e5f953
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/poetry/console/commands/group_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -93,9 +102,9 @@ def activated_groups(self) -> set[str]:
"</warning>"
)

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(
Expand Down

0 comments on commit 0e5f953

Please sign in to comment.