Fix ruff rules E711,E712,F841 (#2314)

* Fix ruff rules E711,E712,F841

* Remove unused re (_rex) and import

---------

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
This commit is contained in:
Christian Clauss
2025-07-24 03:49:00 -04:00
committed by GitHub
parent e8e2d919b4
commit e7cdcf4b52
3 changed files with 16 additions and 21 deletions
+3 -5
View File
@@ -21,9 +21,8 @@ Released under GNU GPL version 3 or later
""" """
import os import os
import re
from tkinter import * from tkinter import * # noqa: F403
import tkinter.filedialog import tkinter.filedialog
import tkinter.messagebox import tkinter.messagebox
@@ -127,7 +126,7 @@ class Application(Frame):
def browseXMLFile(self): def browseXMLFile(self):
# TODO Allow specification of multiple XML definitions # TODO Allow specification of multiple XML definitions
xml_file = tkinter.filedialog.askopenfilename(parent=self, title='Choose a definition file') xml_file = tkinter.filedialog.askopenfilename(parent=self, title='Choose a definition file')
if xml_file != None: if xml_file is not None:
self.xml_value.set(xml_file) self.xml_value.set(xml_file)
"""\ """\
@@ -137,7 +136,7 @@ class Application(Frame):
def browseOutDirectory(self): def browseOutDirectory(self):
mavlinkFolder = os.path.dirname(os.path.realpath(__file__)) mavlinkFolder = os.path.dirname(os.path.realpath(__file__))
out_dir = tkinter.filedialog.askdirectory(parent=self,initialdir=mavlinkFolder,title='Please select an output directory') out_dir = tkinter.filedialog.askdirectory(parent=self,initialdir=mavlinkFolder,title='Please select an output directory')
if out_dir != None: if out_dir is not None:
self.out_value.set(out_dir) self.out_value.set(out_dir)
"""\ """\
@@ -145,7 +144,6 @@ class Application(Frame):
""" """
def generateHeaders(self): def generateHeaders(self):
# Verify settings # Verify settings
rex = re.compile(".*\\.xml$", re.IGNORECASE)
if not self.xml_value.get(): if not self.xml_value.get():
tkinter.messagebox.showerror('Error Generating Headers','An XML message definition file must be specified.') tkinter.messagebox.showerror('Error Generating Headers','An XML message definition file must be specified.')
return return
+5 -8
View File
@@ -1,8 +1,5 @@
lint.exclude = [ "pymavlink" ] [lint]
lint.extend-ignore = [ exclude = [ "pymavlink" ]
"E711", # none-comparison
"E712", # true-false-comparison [lint.per-file-ignores]
"F403", # undefined-local-with-import-star "mavgenerate.py" = [ "F405" ] # undefined-local-with-import
"F405", # undefined-local-with-import-star-usage
"F841", # unused-variable
]
+8 -8
View File
@@ -39,7 +39,7 @@ def check_enum(enum, file_name):
elif attr == 'bitmask': elif attr == 'bitmask':
bitmask = True bitmask = True
if name == None: if name is None:
raise Exception("%s: No name for Enum: %s" % (file_name, enum)) raise Exception("%s: No name for Enum: %s" % (file_name, enum))
values = [] values = []
@@ -66,7 +66,7 @@ def check_enum(enum, file_name):
bitmask_values.remove(0) bitmask_values.remove(0)
if len(bitmask_values) > 2: if len(bitmask_values) > 2:
if bitmask == None: if bitmask is None:
bitmask = False bitmask = False
overlap = False overlap = False
@@ -95,12 +95,12 @@ def check_field(file_name, msg_name, field, enums):
units = field.get('units') units = field.get('units')
# Enum with units doesn't make sense # Enum with units doesn't make sense
if (enum != None) and (units != None): if enum is not None and units is not None:
print("%s: Message %s field %s has both units and enum" % print("%s: Message %s field %s has both units and enum" %
(file_name, msg_name, name)) (file_name, msg_name, name))
warning_count += 1 warning_count += 1
if (enum != None): if enum is not None:
# Enum should exist # Enum should exist
if enum not in enums: if enum not in enums:
print("%s: Message %s field %s enum %s does not exist" % print("%s: Message %s field %s enum %s does not exist" %
@@ -110,7 +110,7 @@ def check_field(file_name, msg_name, field, enums):
enums[enum]["used"] = True enums[enum]["used"] = True
bitmask = enums[enum]["bitmask"] bitmask = enums[enum]["bitmask"]
if bitmask != None: if bitmask is not None:
# Bitmask should match underlying enum # Bitmask should match underlying enum
display_bitmask = field.get("display") == "bitmask" display_bitmask = field.get("display") == "bitmask"
@@ -144,12 +144,12 @@ def check_cmd_param(file_name, cmd_name, entry, enums):
units = entry.get('units') units = entry.get('units')
# Enum with units doesn't make sense # Enum with units doesn't make sense
if (enum != None) and (units != None): if enum is not None and units is not None:
print("%s: Command %s param %s has both units and enum" % print("%s: Command %s param %s has both units and enum" %
(file_name, cmd_name, index)) (file_name, cmd_name, index))
warning_count += 1 warning_count += 1
if (enum != None): if enum is not None:
# Enum should exist # Enum should exist
if enum not in enums: if enum not in enums:
print("%s: Command %s param %s enum %s does not exist" % print("%s: Command %s param %s enum %s does not exist" %
@@ -278,7 +278,7 @@ for key in xml:
# Check for unused enums # Check for unused enums
for key in all_enums: for key in all_enums:
if all_enums[key]["used"] == False: if all_enums[key]["used"] is False:
print("%s: Enum: %s is unused" % print("%s: Enum: %s is unused" %
(all_enums[key]['file'], all_enums[key]["name"])) (all_enums[key]['file'], all_enums[key]["name"]))
warning_count += 1 warning_count += 1