[3/9] Ignore unsed import in dap/__init__.py

Message ID 20240319-more-flake8-v1-3-893549dbed75@adacore.com
State New
Headers
Series Make gdb/python flake-clean |

Checks

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

Commit Message

Tom Tromey March 19, 2024, 5:33 p.m. UTC
  flake8 warns about dap/__init__.py because it has a number of unused
imports.  Most of these are intentional: the import is done to ensure
that the a DAP request is registered with the server object.

This patch applies a "noqa" comment to these imports, and also removes
one import that is truly unnecessary.
---
 gdb/python/lib/gdb/dap/__init__.py | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)
  

Comments

Tom Tromey March 20, 2024, 3:35 p.m. UTC | #1
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:

Tom> flake8 warns about dap/__init__.py because it has a number of unused
Tom> imports.  Most of these are intentional: the import is done to ensure
Tom> that the a DAP request is registered with the server object.

Tom> This patch applies a "noqa" comment to these imports, and also removes
Tom> one import that is truly unnecessary.

Tom> +from . import breakpoint        # noqa: F401
Tom> +from . import bt                # noqa: F401
Tom> +from . import disassemble       # noqa: F401

I found out 'black' doesn't like this style of comment.
Locally I've run black on each patch in this series, and it affected
just a couple patches like this, removing the extra whitespace.

Tom
  

Patch

diff --git a/gdb/python/lib/gdb/dap/__init__.py b/gdb/python/lib/gdb/dap/__init__.py
index 86da9b8ef3c..f947314880c 100644
--- a/gdb/python/lib/gdb/dap/__init__.py
+++ b/gdb/python/lib/gdb/dap/__init__.py
@@ -14,25 +14,27 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-import gdb
 
 # This must come before other DAP imports.
 from . import startup
 
-# Load modules that define commands.
-from . import breakpoint
-from . import bt
-from . import disassemble
-from . import evaluate
-from . import launch
-from . import locations
-from . import memory
-from . import modules
-from . import next
-from . import pause
-from . import scopes
-from . import sources
-from . import threads
+# Load modules that define commands.  These imports intentionally
+# ignore the unused import warning, as these modules are being loaded
+# for their side effects -- namely, registering DAP commands with the
+# server object.  "F401" is the flake8 "imported but unused" code.
+from . import breakpoint        # noqa: F401
+from . import bt                # noqa: F401
+from . import disassemble       # noqa: F401
+from . import evaluate          # noqa: F401
+from . import launch            # noqa: F401
+from . import locations         # noqa: F401
+from . import memory            # noqa: F401
+from . import modules           # noqa: F401
+from . import next              # noqa: F401
+from . import pause             # noqa: F401
+from . import scopes            # noqa: F401
+from . import sources           # noqa: F401
+from . import threads           # noqa: F401
 
 from .server import Server