Skip to content

Commit

Permalink
FIX: all current linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Nov 19, 2024
1 parent cc42993 commit d73fe28
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Install dependencies
run: |
python -m pip install -U mypy
python -m pip install -U mypy types-requests
- name: Lint the code with mypy
uses: sasanquaneuf/mypy-github-action@releases/v1.3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install 'pylint<=3.2.7'
pip install 'pylint>=3.3.1'
- name: Analysing the code with pylint
run: |
Expand Down
4 changes: 2 additions & 2 deletions MethodicConfigurator/annotate_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def load_param_file_into_dict(param_file: str) -> dict[str, "Par"]:
return parameter_dict

@staticmethod
def validate_parameter(param_file, parameter_dict, i, original_line, comment, parameter, value) -> None: # pylint: disable=too-many-arguments
def validate_parameter(param_file, parameter_dict, i, original_line, comment, parameter, value) -> None: # pylint: disable=too-many-arguments, too-many-positional-arguments
if len(parameter) > PARAM_NAME_MAX_LEN:
raise SystemExit(f"Too long parameter name: {parameter} in {param_file} line {i}")
if not re.match(PARAM_NAME_REGEX, parameter):
Expand Down Expand Up @@ -639,7 +639,7 @@ def update_parameter_documentation(
)


def update_parameter_documentation_file( # pylint: disable=too-many-locals, too-many-arguments
def update_parameter_documentation_file( # pylint: disable=too-many-locals, too-many-arguments, too-many-positional-arguments
doc,
sort_type,
param_default_dict,
Expand Down
2 changes: 1 addition & 1 deletion MethodicConfigurator/backend_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from typing import Any, Optional
from zipfile import ZipFile

from requests import get as requests_get # type: ignore[import-untyped]
from requests import get as requests_get

from MethodicConfigurator import _
from MethodicConfigurator.annotate_params import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __validate_parameters_in_configuration_steps(self, filename: str, file_info:
parameter,
)

def compute_parameters(self, filename: str, file_info: dict, parameter_type: str, variables: dict) -> str:
def compute_parameters(self, filename: str, file_info: dict, parameter_type: str, variables: dict) -> str: # pylint: disable=too-many-branches
"""
Computes the forced or derived parameters for a given configuration file.
Expand All @@ -122,7 +122,7 @@ def compute_parameters(self, filename: str, file_info: dict, parameter_type: str
if parameter_type + "_parameters" not in file_info or not variables:
return ""
destination = self.forced_parameters if parameter_type == "forced" else self.derived_parameters
for parameter, parameter_info in file_info[parameter_type + "_parameters"].items():
for parameter, parameter_info in file_info[parameter_type + "_parameters"].items(): # pylint: disable=too-many-nested-blocks
try:
if ("fc_parameters" in str(parameter_info["New Value"])) and (
"fc_parameters" not in variables or variables["fc_parameters"] == {}
Expand Down
7 changes: 4 additions & 3 deletions MethodicConfigurator/backend_filesystem_program_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __user_config_dir() -> str:
error_msg = _("The path '{user_config_directory}' is not a directory.")
raise NotADirectoryError(error_msg.format(**locals()))

return user_config_directory
return user_config_directory # type: ignore[no-any-return] # workaround a mypy bug

@staticmethod
def __site_config_dir() -> str:
Expand All @@ -115,7 +115,7 @@ def __site_config_dir() -> str:
error_msg = _("The path '{site_config_directory}' is not a directory.")
raise NotADirectoryError(error_msg.format(**locals()))

return site_config_directory
return site_config_directory # type: ignore[no-any-return] # workaround a mypy bug

@staticmethod
def __get_settings_as_dict() -> dict[str, Any]:
Expand Down Expand Up @@ -250,7 +250,8 @@ def set_display_usage_popup(ptype: str, value: bool) -> None:
@staticmethod
def get_setting(setting: str) -> Union[int, bool]:
if setting in SETTINGS_DEFAULTS:
return ProgramSettings.__get_settings_as_dict().get(setting, SETTINGS_DEFAULTS[setting]) # type: ignore[no-any-return]
setting_default = SETTINGS_DEFAULTS[setting]
return ProgramSettings.__get_settings_as_dict().get(setting, setting_default) # type: ignore[no-any-return]
return False

@staticmethod
Expand Down
6 changes: 3 additions & 3 deletions MethodicConfigurator/backend_mavftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class FTP_OP: # pylint: disable=invalid-name, too-many-instance-attributes
including the necessary parameters and payload for the operation.
"""

def __init__( # pylint: disable=too-many-arguments
def __init__( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
seq,
session,
Expand Down Expand Up @@ -216,7 +216,7 @@ def __setattr__(self, name, value) -> None:
class MAVFTPReturn:
"""The result of a MAVFTP operation."""

def __init__( # pylint: disable=too-many-arguments
def __init__( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
operation_name: str,
error_code: int,
Expand Down Expand Up @@ -1348,7 +1348,7 @@ def save_params(
f.write("\n")
logging.info("Outputted %u parameters to %s", len(pdict), filename)

def cmd_getparams( # pylint: disable=too-many-arguments
def cmd_getparams( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
args,
progress_callback=None,
Expand Down
6 changes: 3 additions & 3 deletions MethodicConfigurator/frontend_tkinter_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class ProgressWindow:
a task. It includes a progress bar and a label to display the progress message.
"""

def __init__(self, parent, title: str, message: str = "", width: int = 300, height: int = 80) -> None: # pylint: disable=too-many-arguments
def __init__(self, parent, title: str, message: str = "", width: int = 300, height: int = 80) -> None: # pylint: disable=too-many-arguments, too-many-positional-arguments
self.parent = parent
self.message = message
self.progress_window = tk.Toplevel(self.parent)
Expand Down Expand Up @@ -384,7 +384,7 @@ def put_image_in_label(parent: ttk.Frame, filepath: str, image_height: int = 40)
photo = ImageTk.PhotoImage(resized_image)

# Create a label with the resized image
image_label = ttk.Label(parent, image=photo) # type: ignore[arg-type]
image_label = ttk.Label(parent, image=photo)
# Keep a reference to the image to prevent it from being garbage collected
image_label.image = photo # type: ignore
return image_label
Expand All @@ -406,7 +406,7 @@ def should_display(ptype: str) -> bool:
return ProgramSettings.display_usage_popup(ptype)

@staticmethod
def display( # pylint: disable=too-many-arguments
def display( # pylint: disable=too-many-arguments, too-many-positional-arguments
parent: tk.Toplevel,
usage_popup_window: BaseWindow,
title: str,
Expand Down
2 changes: 1 addition & 1 deletion MethodicConfigurator/frontend_tkinter_component_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def validate_combobox(self, event: tk.Event, path: tuple[str, ...]) -> bool:
combobox.configure(style="comb_input_valid.TCombobox")
return True

def validate_entry_limits(self, event, entry, data_type, limits, _name, path) -> bool: # pylint: disable=too-many-arguments
def validate_entry_limits(self, event, entry, data_type, limits, _name, path) -> bool: # pylint: disable=too-many-arguments, too-many-positional-arguments
is_focusout_event = event and event.type == "10"
try:
value = entry.get() # make sure value is defined to prevent exception in the except block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ConnectionSelectionWidgets: # pylint: disable=too-many-instance-attribute
allowing the user to select a connection, and handling the connection process.
"""

def __init__( # pylint: disable=too-many-arguments
def __init__( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
parent,
parent_frame,
Expand Down
4 changes: 2 additions & 2 deletions MethodicConfigurator/frontend_tkinter_directory_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DirectorySelectionWidgets:
directory selection dialog.
"""

def __init__( # pylint: disable=too-many-arguments
def __init__( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
parent: BaseWindow,
parent_frame: tk.Widget,
Expand Down Expand Up @@ -145,7 +145,7 @@ class VehicleDirectorySelectionWidgets(DirectorySelectionWidgets):
selected vehicle directory and re-initializing the filesystem with the new directory.
"""

def __init__( # pylint: disable=too-many-arguments
def __init__( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
parent: BaseWindow,
parent_frame: ttk.Widget,
Expand Down
2 changes: 1 addition & 1 deletion MethodicConfigurator/frontend_tkinter_entry_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EntryWithDynamicalyFilteredListbox(Entry): # pylint: disable=too-many-anc
Entry with dynamicaly filtered ListBox to emulate an inteligent combobox widget
"""

def __init__( # pylint: disable=too-many-arguments
def __init__( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
master,
list_of_items=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def __update_new_value_entry_text(new_value_entry: ttk.Entry, value: float, para
else:
new_value_entry.configure(style="TEntry")

def __create_new_value_entry( # pylint: disable=too-many-arguments
def __create_new_value_entry( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
param_name,
param,
Expand Down
2 changes: 1 addition & 1 deletion MethodicConfigurator/mavftp_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import backend_mavftp as mavftp

# import time
import requests # type: ignore[import-untyped]
import requests
from pymavlink import mavutil

old_mavftp_member_variable_values: dict[str, Any] = {}
Expand Down
8 changes: 4 additions & 4 deletions MethodicConfigurator/tempcal_imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def set_accel_tcal(self, imu, value) -> None:
def set_enable(self, imu, value) -> None:
self.enable[imu] = value

def correction(self, coeff, imu, temperature, axis, cal_temp) -> float: # pylint: disable=too-many-arguments
def correction(self, coeff, imu, temperature, axis, cal_temp) -> float: # pylint: disable=too-many-arguments, too-many-positional-arguments
"""calculate correction from temperature calibration from log data using parameters"""
if self.enable[imu] != 1.0:
return 0.0
Expand Down Expand Up @@ -286,7 +286,7 @@ def constrain(value, minv, maxv) -> Union[float, int]:
return value # type: ignore


def IMUfit( # noqa: PLR0915 pylint: disable=too-many-locals, too-many-branches, too-many-statements, too-many-arguments
def IMUfit( # noqa: PLR0915 pylint: disable=too-many-locals, too-many-branches, too-many-statements, too-many-arguments, too-many-positional-arguments
logfile,
outfile,
no_graph,
Expand Down Expand Up @@ -539,7 +539,7 @@ def generate_calibration_file(outfile, online, progress_callback, data, c) -> tu
return c, clog


def generate_tempcal_gyro_figures(log_parm, figpath, data, c, clog, num_imus) -> None: # pylint: disable=too-many-arguments
def generate_tempcal_gyro_figures(log_parm, figpath, data, c, clog, num_imus) -> None: # pylint: disable=too-many-arguments, too-many-positional-arguments
_fig, axs = plt.subplots(len(data.IMUs()), 1, sharex=True)
if num_imus == 1:
axs = [axs]
Expand Down Expand Up @@ -573,7 +573,7 @@ def generate_tempcal_gyro_figures(log_parm, figpath, data, c, clog, num_imus) ->
_fig.savefig(os.path.join(figpath, "tempcal_gyro.png"))


def generate_tempcal_accel_figures(log_parm, figpath, data, c, clog, num_imus) -> None: # pylint: disable=too-many-arguments
def generate_tempcal_accel_figures(log_parm, figpath, data, c, clog, num_imus) -> None: # pylint: disable=too-many-arguments, too-many-positional-arguments
_fig, axs = plt.subplots(num_imus, 1, sharex=True)
if num_imus == 1:
axs = [axs]
Expand Down

0 comments on commit d73fe28

Please sign in to comment.