[libcamera-devel,3/4] utils: checkstyle.py: Derive Amendment from Commit
diff mbox series

Message ID 20230711133915.650485-4-kieran.bingham@ideasonboard.com
State Accepted
Commit e2f0ad27b18b1502f59268bda2eeff4a7a21055c
Headers show
Series
  • utils: checkstyle.py: Fix Trailer handling
Related show

Commit Message

Kieran Bingham July 11, 2023, 1:39 p.m. UTC
The Amendment commit class is derived from the StagedChanges class
(which in turn derives from the Commit base class), however there is no
code sharing between Amendment and StagedChanges other than the call to
initalise through the base Commit class.

Refactor the inheritance to make an Amendment derive directly from
Commit.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 utils/checkstyle.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Umang Jain July 11, 2023, 1:49 p.m. UTC | #1
Hi,

On 7/11/23 7:09 PM, Kieran Bingham via libcamera-devel wrote:
> The Amendment commit class is derived from the StagedChanges class
> (which in turn derives from the Commit base class), however there is no
> code sharing between Amendment and StagedChanges other than the call to
> initalise through the base Commit class.
>
> Refactor the inheritance to make an Amendment derive directly from
> Commit.

This makes so much sense already just by reading it ;-)
>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

> ---
>   utils/checkstyle.py | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/utils/checkstyle.py b/utils/checkstyle.py
> index 2ba3165b8ecd..5663af811961 100755
> --- a/utils/checkstyle.py
> +++ b/utils/checkstyle.py
> @@ -269,9 +269,9 @@ class StagedChanges(Commit):
>           return parse_diff(diff.splitlines(True))
>   
>   
> -class Amendment(StagedChanges):
> +class Amendment(Commit):
>       def __init__(self):
> -        StagedChanges.__init__(self)
> +        Commit.__init__(self, '')
>   
>       def _parse(self):
>           # Create a title using HEAD commit

Patch
diff mbox series

diff --git a/utils/checkstyle.py b/utils/checkstyle.py
index 2ba3165b8ecd..5663af811961 100755
--- a/utils/checkstyle.py
+++ b/utils/checkstyle.py
@@ -269,9 +269,9 @@  class StagedChanges(Commit):
         return parse_diff(diff.splitlines(True))
 
 
-class Amendment(StagedChanges):
+class Amendment(Commit):
     def __init__(self):
-        StagedChanges.__init__(self)
+        Commit.__init__(self, '')
 
     def _parse(self):
         # Create a title using HEAD commit