Fix two minor flake8 issues

Message ID 20240223190145.3629627-1-tromey@adacore.com
State New
Headers
Series Fix two minor flake8 issues |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom Tromey Feb. 23, 2024, 7:01 p.m. UTC
  flake8 pointed out some extra whitespace around ':' in some Python
code.
---
 gdb/python/lib/gdb/command/frame_filters.py | 2 +-
 gdb/python/lib/gdb/prompt.py                | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  

Comments

Simon Marchi Feb. 23, 2024, 7:33 p.m. UTC | #1
On 2024-02-23 14:01, Tom Tromey wrote:
> flake8 pointed out some extra whitespace around ':' in some Python
> code.

If we change these, black is going to immediately want to revert them.

We need to tell flake8 to ignore these formatting warnings, since the
formatting is all taken care of.  See:

https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8

I propose to just add this in gdb/.flake8 or gdb/setup.cfg, as the page
suggests:

[flake8]
max-line-length = 88
extend-ignore = E203,E701

Simon
  
Tom Tromey Feb. 23, 2024, 7:39 p.m. UTC | #2
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> If we change these, black is going to immediately want to revert them.

lol I forgot about this.

Simon> I propose to just add this in gdb/.flake8 or gdb/setup.cfg, as the page
Simon> suggests:

Simon> [flake8]
Simon> max-line-length = 88
Simon> extend-ignore = E203,E701

Please do.

Internally I see we use:

# See
# https://github.com/psf/black/blob/master/docs/compatible_configs.md#black-compatible-configurations
# to understand the max-line-length and extend-ignore settings.
max-line-length = 88
extend-ignore: E203, W503, B906, B907

I don't remember what these other ones are about.

Tom
  

Patch

diff --git a/gdb/python/lib/gdb/command/frame_filters.py b/gdb/python/lib/gdb/command/frame_filters.py
index 47045518e64..41f61ff19bc 100644
--- a/gdb/python/lib/gdb/command/frame_filters.py
+++ b/gdb/python/lib/gdb/command/frame_filters.py
@@ -191,7 +191,7 @@  def _complete_frame_filter_list(text, word, all_flag):
 
     # If we only have one completion, complete it and return it.
     if len(flist) == 1:
-        flist[0] = flist[0][len(text) - len(word) :]
+        flist[0] = flist[0][len(text) - len(word):]
 
     # Otherwise, return an empty list, or a list of frame filter
     # dictionaries that the previous filter operation returned.
diff --git a/gdb/python/lib/gdb/prompt.py b/gdb/python/lib/gdb/prompt.py
index 02185b353df..e00e4b0a521 100644
--- a/gdb/python/lib/gdb/prompt.py
+++ b/gdb/python/lib/gdb/prompt.py
@@ -146,7 +146,7 @@  def substitute_prompt(prompt):
                     if j >= plen or prompt[j] != "}":
                         arg = None
                     else:
-                        arg = prompt[i + 2 : j]
+                        arg = prompt[i + 2:j]
                         i = j
                 else:
                     arg = None