From ff453d215a3244644ef207f2d5d065f680016da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 10 Jul 2024 23:20:01 -0400 Subject: [PATCH] style: Fix get-attr-with-constant (B009) (#4009) --- gui/wxpython/modules/colorrules.py | 4 ++-- pyproject.toml | 1 - scripts/wxpyimgview/wxpyimgview_gui.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gui/wxpython/modules/colorrules.py b/gui/wxpython/modules/colorrules.py index 73cd2dac9b9..5ded54c8be8 100644 --- a/gui/wxpython/modules/colorrules.py +++ b/gui/wxpython/modules/colorrules.py @@ -1901,12 +1901,12 @@ def _columnWidgetEvtHandler(self, bind=True): ] for widget in widgets: if bind is True: - getattr(widget["widget"], "Bind")( + widget["widget"].Bind( widget["event"], widget["handler"], ) else: - getattr(widget["widget"], "Unbind")(widget["event"]) + widget["widget"].Unbind(widget["event"]) class ThematicVectorTable(VectorColorTable): diff --git a/pyproject.toml b/pyproject.toml index 8404c018ab3..02479d6b5a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,6 @@ ignore = [ "B006", # mutable-argument-default "B007", # unused-loop-control-variable "B008", # function-call-in-default-argument - "B009", # get-attr-with-constant "B015", # useless-comparison "B023", # function-uses-loop-variable "B026", # star-arg-unpacking-after-keyword-arg diff --git a/scripts/wxpyimgview/wxpyimgview_gui.py b/scripts/wxpyimgview/wxpyimgview_gui.py index 1ce955c47e6..b0f89deee80 100644 --- a/scripts/wxpyimgview/wxpyimgview_gui.py +++ b/scripts/wxpyimgview/wxpyimgview_gui.py @@ -83,7 +83,7 @@ def draw(self): dc = wx.PaintDC(self) data = app.imgbuf.reshape((app.i_height, app.i_width, 4)) data = data[::, ::, 2::-1] - fn = getattr(data, "tobytes", getattr(data, "tostring")) + fn = getattr(data, "tobytes", data.tostring) image = wx.Image(app.i_width, app.i_height, fn()) dc.DrawBitmap(BitmapFromImage(image), x0, y0, False)