From 49bb19898cb052457251b83d6620eeccb2f9d628 Mon Sep 17 00:00:00 2001
From: Daniel1464 <Daniel_Chen@caryacademy.org>
Date: Thu, 3 Oct 2024 21:29:49 -0400
Subject: [PATCH 1/2] [commands] Clarified error messages for parallel
 composition commands (#6353)

---
 commands2/parallelcommandgroup.py  | 5 ++++-
 commands2/paralleldeadlinegroup.py | 5 ++++-
 commands2/parallelracegroup.py     | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/commands2/parallelcommandgroup.py b/commands2/parallelcommandgroup.py
index 897e5ab0..9645757e 100644
--- a/commands2/parallelcommandgroup.py
+++ b/commands2/parallelcommandgroup.py
@@ -49,8 +49,11 @@ def addCommands(self, *commands: Command):
         for command in commands:
             in_common = command.getRequirements().intersection(self.requirements)
             if in_common:
+                requirements_str = ", ".join([s.getName() for s in command.getRequirements()])
                 raise IllegalCommandUse(
-                    "Multiple commands in a parallel composition cannot require the same subsystems.",
+                    f"Command {command.getName()} could not be added to this ParallelCommandGroup"
+                    f" because the subsystems [{requirements_str}] are already required in this command."
+                    f" Multiple commands in a parallel composition cannot require the same subsystems.",
                     common=in_common,
                 )
 
diff --git a/commands2/paralleldeadlinegroup.py b/commands2/paralleldeadlinegroup.py
index 6a06cefe..967a4c26 100644
--- a/commands2/paralleldeadlinegroup.py
+++ b/commands2/paralleldeadlinegroup.py
@@ -85,8 +85,11 @@ def addCommands(self, *commands: Command):
         for command in commands:
             in_common = command.getRequirements().intersection(self.requirements)
             if in_common:
+                requirements_str = ", ".join([s.getName() for s in command.getRequirements()])
                 raise IllegalCommandUse(
-                    "Multiple commands in a parallel composition cannot require the same subsystems.",
+                    f"Command {command.getName()} could not be added to this ParallelCommandGroup"
+                    f" because the subsystems [{requirements_str}] are already required in this command."
+                    f" Multiple commands in a parallel composition cannot require the same subsystems.",
                     common=in_common,
                 )
 
diff --git a/commands2/parallelracegroup.py b/commands2/parallelracegroup.py
index 032003d5..6b04da62 100644
--- a/commands2/parallelracegroup.py
+++ b/commands2/parallelracegroup.py
@@ -51,8 +51,11 @@ def addCommands(self, *commands: Command):
         for command in commands:
             in_common = command.getRequirements().intersection(self.requirements)
             if in_common:
+                requirements_str = ", ".join([s.getName() for s in command.getRequirements()])
                 raise IllegalCommandUse(
-                    "Multiple commands in a parallel composition cannot require the same subsystems.",
+                    f"Command {command.getName()} could not be added to this ParallelCommandGroup"
+                    f" because the subsystems [{requirements_str}] are already required in this command."
+                    f" Multiple commands in a parallel composition cannot require the same subsystems.",
                     common=in_common,
                 )
 

From fd26e1457e9b5aecd956ce46312e32c70e797a78 Mon Sep 17 00:00:00 2001
From: Daniel Chen <Daniel_Chen@caryacademy.org>
Date: Sun, 6 Oct 2024 16:15:53 -0400
Subject: [PATCH 2/2] Formatting, made requirements error more specific

---
 commands2/parallelcommandgroup.py  | 4 +++-
 commands2/paralleldeadlinegroup.py | 4 +++-
 commands2/parallelracegroup.py     | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/commands2/parallelcommandgroup.py b/commands2/parallelcommandgroup.py
index 9645757e..1a277798 100644
--- a/commands2/parallelcommandgroup.py
+++ b/commands2/parallelcommandgroup.py
@@ -49,7 +49,9 @@ def addCommands(self, *commands: Command):
         for command in commands:
             in_common = command.getRequirements().intersection(self.requirements)
             if in_common:
-                requirements_str = ", ".join([s.getName() for s in command.getRequirements()])
+                requirements_str = ", ".join(
+                    [s.getName() for s in in_common]
+                )
                 raise IllegalCommandUse(
                     f"Command {command.getName()} could not be added to this ParallelCommandGroup"
                     f" because the subsystems [{requirements_str}] are already required in this command."
diff --git a/commands2/paralleldeadlinegroup.py b/commands2/paralleldeadlinegroup.py
index 967a4c26..7fb4f9a0 100644
--- a/commands2/paralleldeadlinegroup.py
+++ b/commands2/paralleldeadlinegroup.py
@@ -85,7 +85,9 @@ def addCommands(self, *commands: Command):
         for command in commands:
             in_common = command.getRequirements().intersection(self.requirements)
             if in_common:
-                requirements_str = ", ".join([s.getName() for s in command.getRequirements()])
+                requirements_str = ", ".join(
+                    [s.getName() for s in in_common]
+                )
                 raise IllegalCommandUse(
                     f"Command {command.getName()} could not be added to this ParallelCommandGroup"
                     f" because the subsystems [{requirements_str}] are already required in this command."
diff --git a/commands2/parallelracegroup.py b/commands2/parallelracegroup.py
index 6b04da62..04f21129 100644
--- a/commands2/parallelracegroup.py
+++ b/commands2/parallelracegroup.py
@@ -51,7 +51,9 @@ def addCommands(self, *commands: Command):
         for command in commands:
             in_common = command.getRequirements().intersection(self.requirements)
             if in_common:
-                requirements_str = ", ".join([s.getName() for s in command.getRequirements()])
+                requirements_str = ", ".join(
+                    [s.getName() for s in in_common]
+                )
                 raise IllegalCommandUse(
                     f"Command {command.getName()} could not be added to this ParallelCommandGroup"
                     f" because the subsystems [{requirements_str}] are already required in this command."