[PATCH 12/26] rv/rvgen: fix PEP 8 whitespace violations

Wander Lairson Costa posted 26 patches 2 weeks, 5 days ago
There is a newer version of this series
[PATCH 12/26] rv/rvgen: fix PEP 8 whitespace violations
Posted by Wander Lairson Costa 2 weeks, 5 days ago
Fix whitespace violations throughout the rvgen codebase to comply
with PEP 8 style guidelines. The changes address missing whitespace
after commas, around operators, and in collection literals that
were flagged by pycodestyle.

The fixes include adding whitespace after commas in string replace
chains and function arguments, adding whitespace around arithmetic
operators, removing extra whitespace in list comprehensions, and
fixing dictionary literal spacing. These changes improve code
readability and consistency with Python coding standards.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
---
 tools/verification/rvgen/rvgen/automata.py  | 12 ++++++------
 tools/verification/rvgen/rvgen/dot2c.py     |  2 +-
 tools/verification/rvgen/rvgen/dot2k.py     |  4 ++--
 tools/verification/rvgen/rvgen/generator.py |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/verification/rvgen/rvgen/automata.py b/tools/verification/rvgen/rvgen/automata.py
index c0c8d13030007..9e1c097ad0e4a 100644
--- a/tools/verification/rvgen/rvgen/automata.py
+++ b/tools/verification/rvgen/rvgen/automata.py
@@ -95,7 +95,7 @@ class Automata:
             raw_state = line[-1]
 
             #  "enabled_fired"}; -> enabled_fired
-            state = raw_state.replace('"', '').replace('};', '').replace(',','_')
+            state = raw_state.replace('"', '').replace('};', '').replace(',', '_')
             if state[0:7] == "__init_":
                 initial_state = state[7:]
             else:
@@ -132,7 +132,7 @@ class Automata:
             #  ------------ event is here ------------^^^^^
             if self.__dot_lines[cursor].split()[1] == "->":
                 line = self.__dot_lines[cursor].split()
-                event = line[-2].replace('"','')
+                event = line[-2].replace('"', '')
 
                 # when a transition has more than one labels, they are like this
                 # "local_irq_enable\nhw_local_irq_enable_n"
@@ -162,7 +162,7 @@ class Automata:
             nr_state += 1
 
         # declare the matrix....
-        matrix = [[ self.invalid_state_str for x in range(nr_event)] for y in range(nr_state)]
+        matrix = [[self.invalid_state_str for x in range(nr_event)] for y in range(nr_state)]
 
         # and we are back! Let's fill the matrix
         cursor = self.__get_cursor_begin_events()
@@ -170,9 +170,9 @@ class Automata:
         while self.__dot_lines[cursor].lstrip()[0] == '"':
             if self.__dot_lines[cursor].split()[1] == "->":
                 line = self.__dot_lines[cursor].split()
-                origin_state = line[0].replace('"','').replace(',','_')
-                dest_state = line[2].replace('"','').replace(',','_')
-                possible_events = line[-2].replace('"','').replace("\\n", " ")
+                origin_state = line[0].replace('"', '').replace(',', '_')
+                dest_state = line[2].replace('"', '').replace(',', '_')
+                possible_events = line[-2].replace('"', '').replace("\\n", " ")
                 for event in possible_events.split():
                     matrix[states_dict[origin_state]][events_dict[event]] = dest_state
             cursor += 1
diff --git a/tools/verification/rvgen/rvgen/dot2c.py b/tools/verification/rvgen/rvgen/dot2c.py
index fa9e9ae16640f..b291c29160fc2 100644
--- a/tools/verification/rvgen/rvgen/dot2c.py
+++ b/tools/verification/rvgen/rvgen/dot2c.py
@@ -172,7 +172,7 @@ class Dot2c(Automata):
                     line += f"\t\t\t{next_state}"
                 else:
                     line += f"{next_state:>{maxlen}}"
-                if y != nr_events-1:
+                if y != nr_events - 1:
                     line += ",\n" if linetoolong else ", "
                 else:
                     line += "\n\t\t}," if linetoolong else " },"
diff --git a/tools/verification/rvgen/rvgen/dot2k.py b/tools/verification/rvgen/rvgen/dot2k.py
index 291385adb2c20..de44840f63eda 100644
--- a/tools/verification/rvgen/rvgen/dot2k.py
+++ b/tools/verification/rvgen/rvgen/dot2k.py
@@ -109,8 +109,8 @@ class dot2k(Monitor, Dot2c):
         tp_args = tp_args_event if tp_type == "event" else tp_args_error
         if self.monitor_type == "per_task":
             tp_args.insert(0, tp_args_id)
-        tp_proto_c = ", ".join([a+b for a,b in tp_args])
-        tp_args_c = ", ".join([b for a,b in tp_args])
+        tp_proto_c = ", ".join([a + b for a, b in tp_args])
+        tp_args_c = ", ".join([b for a, b in tp_args])
         buff.append(f"	     TP_PROTO({tp_proto_c}),")
         buff.append(f"	     TP_ARGS({tp_args_c})")
         return '\n'.join(buff)
diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verification/rvgen/rvgen/generator.py
index ea1fa0f5d818d..0491f8c9cb0b9 100644
--- a/tools/verification/rvgen/rvgen/generator.py
+++ b/tools/verification/rvgen/rvgen/generator.py
@@ -229,7 +229,7 @@ obj-$(CONFIG_RV_MON_{name_up}) += monitors/{name}/{name}.o
 
 
 class Monitor(RVGenerator):
-    monitor_types = { "global" : 1, "per_cpu" : 2, "per_task" : 3 }
+    monitor_types = {"global": 1, "per_cpu": 2, "per_task": 3}
 
     def __init__(self, extra_params={}):
         super().__init__(extra_params)
-- 
2.52.0
Re: [PATCH 12/26] rv/rvgen: fix PEP 8 whitespace violations
Posted by Nam Cao 2 weeks, 2 days ago
Wander Lairson Costa <wander@redhat.com> writes:

> Fix whitespace violations throughout the rvgen codebase to comply
> with PEP 8 style guidelines. The changes address missing whitespace
> after commas, around operators, and in collection literals that
> were flagged by pycodestyle.
>
> The fixes include adding whitespace after commas in string replace
> chains and function arguments, adding whitespace around arithmetic
> operators, removing extra whitespace in list comprehensions, and
> fixing dictionary literal spacing. These changes improve code
> readability and consistency with Python coding standards.
>
> Signed-off-by: Wander Lairson Costa <wander@redhat.com>

Reviewed-by: Nam Cao <namcao@linutronix.de>
Re: [PATCH 12/26] rv/rvgen: fix PEP 8 whitespace violations
Posted by Gabriele Monaco 2 weeks, 5 days ago
On Mon, 2026-01-19 at 17:45 -0300, Wander Lairson Costa wrote:
> Fix whitespace violations throughout the rvgen codebase to comply
> with PEP 8 style guidelines. The changes address missing whitespace
> after commas, around operators, and in collection literals that
> were flagged by pycodestyle.
> 
> The fixes include adding whitespace after commas in string replace
> chains and function arguments, adding whitespace around arithmetic
> operators, removing extra whitespace in list comprehensions, and
> fixing dictionary literal spacing. These changes improve code
> readability and consistency with Python coding standards.
> 
> Signed-off-by: Wander Lairson Costa <wander@redhat.com>

Looks good, thanks

Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>

> ---
>  tools/verification/rvgen/rvgen/automata.py  | 12 ++++++------
>  tools/verification/rvgen/rvgen/dot2c.py     |  2 +-
>  tools/verification/rvgen/rvgen/dot2k.py     |  4 ++--
>  tools/verification/rvgen/rvgen/generator.py |  2 +-
>  4 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/verification/rvgen/rvgen/automata.py
> b/tools/verification/rvgen/rvgen/automata.py
> index c0c8d13030007..9e1c097ad0e4a 100644
> --- a/tools/verification/rvgen/rvgen/automata.py
> +++ b/tools/verification/rvgen/rvgen/automata.py
> @@ -95,7 +95,7 @@ class Automata:
>              raw_state = line[-1]
>  
>              #  "enabled_fired"}; -> enabled_fired
> -            state = raw_state.replace('"', '').replace('};',
> '').replace(',','_')
> +            state = raw_state.replace('"', '').replace('};', '').replace(',',
> '_')
>              if state[0:7] == "__init_":
>                  initial_state = state[7:]
>              else:
> @@ -132,7 +132,7 @@ class Automata:
>              #  ------------ event is here ------------^^^^^
>              if self.__dot_lines[cursor].split()[1] == "->":
>                  line = self.__dot_lines[cursor].split()
> -                event = line[-2].replace('"','')
> +                event = line[-2].replace('"', '')
>  
>                  # when a transition has more than one labels, they are like
> this
>                  # "local_irq_enable\nhw_local_irq_enable_n"
> @@ -162,7 +162,7 @@ class Automata:
>              nr_state += 1
>  
>          # declare the matrix....
> -        matrix = [[ self.invalid_state_str for x in range(nr_event)] for y in
> range(nr_state)]
> +        matrix = [[self.invalid_state_str for x in range(nr_event)] for y in
> range(nr_state)]
>  
>          # and we are back! Let's fill the matrix
>          cursor = self.__get_cursor_begin_events()
> @@ -170,9 +170,9 @@ class Automata:
>          while self.__dot_lines[cursor].lstrip()[0] == '"':
>              if self.__dot_lines[cursor].split()[1] == "->":
>                  line = self.__dot_lines[cursor].split()
> -                origin_state = line[0].replace('"','').replace(',','_')
> -                dest_state = line[2].replace('"','').replace(',','_')
> -                possible_events = line[-2].replace('"','').replace("\\n", "
> ")
> +                origin_state = line[0].replace('"', '').replace(',', '_')
> +                dest_state = line[2].replace('"', '').replace(',', '_')
> +                possible_events = line[-2].replace('"', '').replace("\\n", "
> ")
>                  for event in possible_events.split():
>                      matrix[states_dict[origin_state]][events_dict[event]] =
> dest_state
>              cursor += 1
> diff --git a/tools/verification/rvgen/rvgen/dot2c.py
> b/tools/verification/rvgen/rvgen/dot2c.py
> index fa9e9ae16640f..b291c29160fc2 100644
> --- a/tools/verification/rvgen/rvgen/dot2c.py
> +++ b/tools/verification/rvgen/rvgen/dot2c.py
> @@ -172,7 +172,7 @@ class Dot2c(Automata):
>                      line += f"\t\t\t{next_state}"
>                  else:
>                      line += f"{next_state:>{maxlen}}"
> -                if y != nr_events-1:
> +                if y != nr_events - 1:
>                      line += ",\n" if linetoolong else ", "
>                  else:
>                      line += "\n\t\t}," if linetoolong else " },"
> diff --git a/tools/verification/rvgen/rvgen/dot2k.py
> b/tools/verification/rvgen/rvgen/dot2k.py
> index 291385adb2c20..de44840f63eda 100644
> --- a/tools/verification/rvgen/rvgen/dot2k.py
> +++ b/tools/verification/rvgen/rvgen/dot2k.py
> @@ -109,8 +109,8 @@ class dot2k(Monitor, Dot2c):
>          tp_args = tp_args_event if tp_type == "event" else tp_args_error
>          if self.monitor_type == "per_task":
>              tp_args.insert(0, tp_args_id)
> -        tp_proto_c = ", ".join([a+b for a,b in tp_args])
> -        tp_args_c = ", ".join([b for a,b in tp_args])
> +        tp_proto_c = ", ".join([a + b for a, b in tp_args])
> +        tp_args_c = ", ".join([b for a, b in tp_args])
>          buff.append(f"	     TP_PROTO({tp_proto_c}),")
>          buff.append(f"	     TP_ARGS({tp_args_c})")
>          return '\n'.join(buff)
> diff --git a/tools/verification/rvgen/rvgen/generator.py
> b/tools/verification/rvgen/rvgen/generator.py
> index ea1fa0f5d818d..0491f8c9cb0b9 100644
> --- a/tools/verification/rvgen/rvgen/generator.py
> +++ b/tools/verification/rvgen/rvgen/generator.py
> @@ -229,7 +229,7 @@ obj-$(CONFIG_RV_MON_{name_up}) += monitors/{name}/{name}.o
>  
>  
>  class Monitor(RVGenerator):
> -    monitor_types = { "global" : 1, "per_cpu" : 2, "per_task" : 3 }
> +    monitor_types = {"global": 1, "per_cpu": 2, "per_task": 3}
>  
>      def __init__(self, extra_params={}):
>          super().__init__(extra_params)