Repository: twisted/twisted

Issue:
The implementation of the AMP protocol used for `trial -j...` could use decorator syntax now
Long ago Python didn't necessarily support decorator syntax.  So, while `Command.responder` was a decorator, it wasn't always used in Twisted using decorator syntax.

Now Python necessarily supports the syntax and we can make the `trial -j ...` support code slightly more idiomatic.



Discussion:

Resolving patch:
diff --git a/src/twisted/trial/_dist/worker.py b/src/twisted/trial/_dist/worker.py
--- a/src/twisted/trial/_dist/worker.py
+++ b/src/twisted/trial/_dist/worker.py
@@ -98,6 +98,7 @@ class LocalWorkerAMP(AMP):
     Local implementation of the manager commands.
     """
 
+    @managercommands.AddSuccess.responder
     def addSuccess(self, testName):
         """
         Add a success to the reporter.
@@ -105,8 +106,6 @@ def addSuccess(self, testName):
         self._result.addSuccess(self._testCase)
         return {"success": True}
 
-    managercommands.AddSuccess.responder(addSuccess)
-
     def _buildFailure(
         self,
         error: WorkerException,
@@ -134,6 +133,7 @@ def _buildFailure(
             )
         return failure
 
+    @managercommands.AddError.responder
     def addError(
         self,
         testName: str,
@@ -154,8 +154,7 @@ def addError(
         self._result.addError(self._testCase, failure)
         return {"success": True}
 
-    managercommands.AddError.responder(addError)
-
+    @managercommands.AddFailure.responder
     def addFailure(
         self,
         testName: str,
@@ -171,8 +170,7 @@ def addFailure(
         self._result.addFailure(self._testCase, failure)
         return {"success": True}
 
-    managercommands.AddFailure.responder(addFailure)
-
+    @managercommands.AddSkip.responder
     def addSkip(self, testName, reason):
         """
         Add a skip to the reporter.
@@ -180,8 +178,7 @@ def addSkip(self, testName, reason):
         self._result.addSkip(self._testCase, reason)
         return {"success": True}
 
-    managercommands.AddSkip.responder(addSkip)
-
+    @managercommands.AddExpectedFailure.responder
     def addExpectedFailure(
         self, testName: str, error: str, todo: Optional[None]
     ) -> Dict[str, bool]:
@@ -192,8 +189,7 @@ def addExpectedFailure(
         self._result.addExpectedFailure(self._testCase, error, _todo)
         return {"success": True}
 
-    managercommands.AddExpectedFailure.responder(addExpectedFailure)
-
+    @managercommands.AddUnexpectedSuccess.responder
     def addUnexpectedSuccess(self, testName, todo):
         """
         Add an unexpected success to the reporter.
@@ -201,8 +197,7 @@ def addUnexpectedSuccess(self, testName, todo):
         self._result.addUnexpectedSuccess(self._testCase, todo)
         return {"success": True}
 
-    managercommands.AddUnexpectedSuccess.responder(addUnexpectedSuccess)
-
+    @managercommands.TestWrite.responder
     def testWrite(self, out):
         """
         Print test output from the worker.
@@ -211,8 +206,6 @@ def testWrite(self, out):
         self._testStream.flush()
         return {"success": True}
 
-    managercommands.TestWrite.responder(testWrite)
-
     def _stopTest(self, result):
         """
         Stop the current running test case, forwarding the result.


Test patch: