From 983901466fe8d77e4910d2392ea1f545aeef5dcf Mon Sep 17 00:00:00 2001 From: torzdf <36920800+torzdf@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:37:48 +0100 Subject: [PATCH] linting: Reduce Class min-public-methods and fix spacing --- lib/align/detected_face.py | 2 +- lib/cli/actions.py | 23 ++++++++----------- lib/cli/args.py | 2 +- lib/cli/launcher.py | 6 ++--- lib/convert.py | 2 +- lib/gpu_stats/directml.py | 4 ++-- lib/gpu_stats/nvidia.py | 2 +- lib/gui/_config.py | 2 +- lib/gui/analysis/event_reader.py | 2 +- lib/gui/analysis/stats.py | 4 ++-- lib/gui/control_helper.py | 4 ++-- lib/gui/custom_widgets.py | 18 +++++++-------- lib/gui/display.py | 4 ++-- lib/gui/display_analysis.py | 4 ++-- lib/gui/display_command.py | 6 ++--- lib/gui/display_graph.py | 18 +++++++-------- lib/gui/display_page.py | 4 ++-- lib/gui/menu.py | 8 +++---- lib/gui/popup_session.py | 4 ++-- lib/gui/project.py | 2 +- lib/gui/theme.py | 4 ++-- lib/gui/utils/config.py | 2 +- lib/gui/utils/file_handler.py | 2 +- lib/gui/utils/image.py | 2 +- lib/gui/utils/misc.py | 2 +- lib/gui/wrapper.py | 2 +- lib/image.py | 4 ++-- lib/keras_utils.py | 2 +- lib/keypress.py | 2 +- lib/model/autoclip.py | 2 +- lib/model/layers.py | 2 +- lib/model/losses/feature_loss.py | 6 ++--- lib/model/networks/simple_nets.py | 4 ++-- lib/multithreading.py | 6 ++--- lib/queue_manager.py | 4 ++-- lib/serializer.py | 4 ++-- lib/sysinfo.py | 6 ++--- lib/training/augmentation.py | 2 +- lib/training/cache.py | 2 +- lib/training/generator.py | 2 +- lib/training/lr_finder.py | 2 +- lib/training/preview_tk.py | 8 +++---- lib/utils.py | 2 +- plugins/convert/color/color_transfer.py | 18 +++++++-------- plugins/convert/color/manual_balance.py | 2 +- plugins/convert/color/seamless_clone.py | 4 ++-- plugins/convert/scaling/sharpen.py | 8 +++---- plugins/convert/writer/_base.py | 2 +- plugins/convert/writer/gif.py | 2 +- plugins/convert/writer/opencv.py | 2 +- plugins/convert/writer/patch.py | 2 +- plugins/convert/writer/pillow.py | 2 +- plugins/extract/align/cv2_dnn.py | 4 ++-- plugins/extract/detect/cv2_dnn.py | 6 ++--- plugins/extract/detect/mtcnn.py | 2 +- plugins/extract/mask/_base.py | 2 +- plugins/extract/recognition/vgg_face2.py | 2 +- plugins/train/_config.py | 2 +- plugins/train/model/_base/model.py | 6 ++--- plugins/train/model/phaze_a.py | 4 ++-- scripts/convert.py | 2 +- scripts/fsmedia.py | 4 ++-- scripts/gui.py | 4 ++-- scripts/train.py | 4 ++-- setup.py | 6 ++--- tools/alignments/media.py | 6 ++--- tools/manual/faceviewer/frame.py | 2 +- tools/manual/frameviewer/editor/_base.py | 2 +- .../manual/frameviewer/editor/bounding_box.py | 2 +- .../manual/frameviewer/editor/extract_box.py | 2 +- tools/manual/frameviewer/editor/landmarks.py | 2 +- tools/manual/frameviewer/frame.py | 4 ++-- tools/preview/control_panels.py | 4 ++-- tools/sort/sort_methods.py | 4 ++-- 74 files changed, 155 insertions(+), 158 deletions(-) diff --git a/lib/align/detected_face.py b/lib/align/detected_face.py index 5cec4bfc8f..15fbb5c393 100644 --- a/lib/align/detected_face.py +++ b/lib/align/detected_face.py @@ -916,7 +916,7 @@ def generate_mask(self, affine_matrix: np.ndarray, interpolator: int) -> None: self.add(mask, affine_matrix, interpolator) -class BlurMask(): # pylint:disable=too-few-public-methods +class BlurMask(): """ Factory class to return the correct blur object for requested blur type. Works for square images only. Currently supports Gaussian and Normalized Box Filters. diff --git a/lib/cli/actions.py b/lib/cli/actions.py index 4b89b35c3a..e3f36ae48c 100644 --- a/lib/cli/actions.py +++ b/lib/cli/actions.py @@ -12,7 +12,7 @@ # << FILE HANDLING >> -class _FullPaths(argparse.Action): # pylint: disable=too-few-public-methods +class _FullPaths(argparse.Action): """ Parent class for various file type and file path handling classes. Expands out given paths to their full absolute paths. This class should not be @@ -42,8 +42,7 @@ class DirFullPaths(_FullPaths): >>> opts=("-f", "--folder_location"), >>> action=DirFullPaths)), """ - # pylint: disable=too-few-public-methods,unnecessary-pass - pass + pass # pylint:disable=unnecessary-pass class FileFullPaths(_FullPaths): @@ -68,7 +67,6 @@ class FileFullPaths(_FullPaths): >>> action=FileFullPaths, >>> filetypes="video))" """ - # pylint: disable=too-few-public-methods def __init__(self, *args, filetypes: str | None = None, **kwargs) -> None: super().__init__(*args, **kwargs) self.filetypes = filetypes @@ -87,7 +85,7 @@ def _get_kwargs(self): return [(name, getattr(self, name)) for name in names] -class FilesFullPaths(FileFullPaths): # pylint: disable=too-few-public-methods +class FilesFullPaths(FileFullPaths): """ Adds support for a File browser to select multiple files in the GUI. This extends the standard :class:`argparse.Action` and adds an additional parameter @@ -118,7 +116,7 @@ def __init__(self, *args, filetypes: str | None = None, **kwargs) -> None: super().__init__(*args, **kwargs) -class DirOrFileFullPaths(FileFullPaths): # pylint: disable=too-few-public-methods +class DirOrFileFullPaths(FileFullPaths): """ Adds support to the GUI to launch either a file browser or a folder browser. Some inputs (for example source frames) can come from a folder of images or from a @@ -147,7 +145,7 @@ class DirOrFileFullPaths(FileFullPaths): # pylint: disable=too-few-public-metho """ -class DirOrFilesFullPaths(FileFullPaths): # pylint: disable=too-few-public-methods +class DirOrFilesFullPaths(FileFullPaths): """ Adds support to the GUI to launch either a file browser for selecting multiple files or a folder browser. @@ -213,8 +211,7 @@ class SaveFileFullPaths(FileFullPaths): >>> action=SaveFileFullPaths, >>> filetypes="video")) """ - # pylint: disable=too-few-public-methods,unnecessary-pass - pass + pass # pylint:disable=unnecessary-pass class ContextFullPaths(FileFullPaths): @@ -247,7 +244,7 @@ class ContextFullPaths(FileFullPaths): >>> filetypes="video", >>> action_option="-a")) """ - # pylint: disable=too-few-public-methods, too-many-arguments + # pylint:disable=too-many-arguments def __init__(self, *args, filetypes: str | None = None, @@ -280,7 +277,7 @@ def _get_kwargs(self) -> list[tuple[str, T.Any]]: # << GUI DISPLAY OBJECTS >> -class Radio(argparse.Action): # pylint: disable=too-few-public-methods +class Radio(argparse.Action): """ Adds support for a GUI Radio options box. This is a standard :class:`argparse.Action` (with stock parameters) which indicates to the GUI @@ -309,7 +306,7 @@ def __call__(self, parser, namespace, values, option_string=None) -> None: setattr(namespace, self.dest, values) -class MultiOption(argparse.Action): # pylint: disable=too-few-public-methods +class MultiOption(argparse.Action): """ Adds support for multiple option checkboxes in the GUI. This is a standard :class:`argparse.Action` (with stock parameters) which indicates to the GUI @@ -337,7 +334,7 @@ def __call__(self, parser, namespace, values, option_string=None) -> None: setattr(namespace, self.dest, values) -class Slider(argparse.Action): # pylint: disable=too-few-public-methods +class Slider(argparse.Action): """ Adds support for a slider in the GUI. The standard :class:`argparse.Action` is extended with the additional parameters listed below. diff --git a/lib/cli/args.py b/lib/cli/args.py index 8193acc4a8..d7a6626f4e 100644 --- a/lib/cli/args.py +++ b/lib/cli/args.py @@ -83,7 +83,7 @@ def _split_lines(self, text: str, width: int) -> list[str]: txt = f" - {txt[2:]}" output.extend(textwrap.wrap(txt, width, subsequent_indent=indent)) return output - return argparse.HelpFormatter._split_lines(self, # pylint: disable=protected-access + return argparse.HelpFormatter._split_lines(self, # pylint:disable=protected-access text, width) diff --git a/lib/cli/launcher.py b/lib/cli/launcher.py index 4745c274d0..98ef321607 100644 --- a/lib/cli/launcher.py +++ b/lib/cli/launcher.py @@ -21,7 +21,7 @@ logger = logging.getLogger(__name__) -class ScriptExecutor(): # pylint:disable=too-few-public-methods +class ScriptExecutor(): """ Loads the relevant script modules and executes the script. This class is initialized in each of the argparsers for the relevant @@ -227,11 +227,11 @@ def execute_script(self, arguments: argparse.Namespace) -> None: except FaceswapError as err: for line in str(err).splitlines(): logger.error(line) - except KeyboardInterrupt: # pylint: disable=try-except-raise + except KeyboardInterrupt: # pylint:disable=try-except-raise raise except SystemExit: pass - except Exception: # pylint: disable=broad-except + except Exception: # pylint:disable=broad-except crash_file = crash_log() logger.exception("Got Exception on main handler:") logger.critical("An unexpected crash has occurred. Crash report written to '%s'. " diff --git a/lib/convert.py b/lib/convert.py index 3b5c91b936..c96b759213 100644 --- a/lib/convert.py +++ b/lib/convert.py @@ -201,7 +201,7 @@ def process(self, in_queue: EventQueue, out_queue: EventQueue): item.inbound.filename) try: image = self._patch_image(item) - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint:disable=broad-except # Log error and output original frame logger.error("Failed to convert image: '%s'. Reason: %s", item.inbound.filename, str(err)) diff --git a/lib/gpu_stats/directml.py b/lib/gpu_stats/directml.py index 46932cd36c..10bb435b93 100644 --- a/lib/gpu_stats/directml.py +++ b/lib/gpu_stats/directml.py @@ -107,7 +107,7 @@ class VendorID(Enum): # STRUCTS -class StructureRepr(Structure): # pylint:disable=too-few-public-methods +class StructureRepr(Structure): """ Override the standard structure class to add a useful __repr__ for logging """ def __repr__(self) -> str: """ Output the class name and the structure contents """ @@ -155,7 +155,7 @@ class DXGIAdapterDesc1(StructureRepr): # pylint:disable=too-few-public-methods ("DedicatedSystemMemory", ctypes.c_size_t), ("SharedSystemMemory", ctypes.c_size_t), ("AdapterLuid", LUID), - ("Flags", DXGIAdapterFlag.ctype)] # type:ignore[attr-defined] # pylint: disable=no-member + ("Flags", DXGIAdapterFlag.ctype)] # type:ignore[attr-defined] # pylint:disable=no-member class DXGIQueryVideoMemoryInfo(StructureRepr): # pylint:disable=too-few-public-methods diff --git a/lib/gpu_stats/nvidia.py b/lib/gpu_stats/nvidia.py index 67038e9c6b..3347399d33 100644 --- a/lib/gpu_stats/nvidia.py +++ b/lib/gpu_stats/nvidia.py @@ -53,7 +53,7 @@ def _initialize(self) -> None: "remove and reinstall your Nvidia drivers before reporting. Original " f"Error: {str(err)}") raise FaceswapError(msg) from err - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint:disable=broad-except msg = ("An unhandled exception occured reading from the Nvidia Machine Learning " f"Library. Original error: {str(err)}") raise FaceswapError(msg) from err diff --git a/lib/gui/_config.py b/lib/gui/_config.py index e5a034b3f6..9f87e3b775 100644 --- a/lib/gui/_config.py +++ b/lib/gui/_config.py @@ -14,7 +14,7 @@ class Config(FaceswapConfig): """ Config File for GUI """ - # pylint: disable=too-many-statements + # pylint:disable=too-many-statements def set_defaults(self): """ Set the default values for config """ logger.debug("Setting defaults") diff --git a/lib/gui/analysis/event_reader.py b/lib/gui/analysis/event_reader.py index 8617150236..60aa45e6e3 100644 --- a/lib/gui/analysis/event_reader.py +++ b/lib/gui/analysis/event_reader.py @@ -618,7 +618,7 @@ def get_timestamps(self, session_id: int | None = None) -> dict[int, np.ndarray] return retval -class _EventParser(): # pylint:disable=too-few-public-methods +class _EventParser(): """ Parses Tensorflow event and populates data to :class:`_Cache`. Parameters diff --git a/lib/gui/analysis/stats.py b/lib/gui/analysis/stats.py index 7c6aab3d43..b055cfa332 100644 --- a/lib/gui/analysis/stats.py +++ b/lib/gui/analysis/stats.py @@ -280,7 +280,7 @@ def get_loss_keys(self, session_id: int | None) -> list[str]: _SESSION = GlobalSession() -class SessionsSummary(): # pylint:disable=too-few-public-methods +class SessionsSummary(): """ Performs top level summary calculations for each session ID within the loaded or currently training Session for display in the Analysis tree view. @@ -853,7 +853,7 @@ def _calc_trend(cls, data: np.ndarray) -> np.ndarray: return trend -class _ExponentialMovingAverage(): # pylint:disable=too-few-public-methods +class _ExponentialMovingAverage(): """ Reshapes data before calculating exponential moving average, then iterates once over the rows to calculate the offset without precision issues. diff --git a/lib/gui/control_helper.py b/lib/gui/control_helper.py index 31c8436e47..1b6571335f 100644 --- a/lib/gui/control_helper.py +++ b/lib/gui/control_helper.py @@ -543,7 +543,7 @@ def add_scrollbar(self): self.mainframe.bind("", self.update_scrollbar) logger.debug("Added Config Scrollbar") - def update_scrollbar(self, event): # pylint: disable=unused-argument + def update_scrollbar(self, event): # pylint:disable=unused-argument """ Update the options frame scrollbar """ self._canvas.configure(scrollregion=self._canvas.bbox("all")) @@ -908,7 +908,7 @@ class ControlBuilder(): blank_nones: bool Sets selected values to an empty string rather than None if this is true. """ - def __init__(self, parent, option, option_columns, # pylint: disable=too-many-arguments + def __init__(self, parent, option, option_columns, # pylint:disable=too-many-arguments label_width, checkbuttons_frame, style, blank_nones): logger.debug("Initializing %s: (parent: %s, option: %s, option_columns: %s, " "label_width: %s, checkbuttons_frame: %s, style: %s, blank_nones: %s)", diff --git a/lib/gui/custom_widgets.py b/lib/gui/custom_widgets.py index 5a39abdb8c..d18d832ed8 100644 --- a/lib/gui/custom_widgets.py +++ b/lib/gui/custom_widgets.py @@ -16,7 +16,7 @@ logger = logging.getLogger(__name__) -class ContextMenu(tk.Menu): # pylint: disable=too-many-ancestors +class ContextMenu(tk.Menu): # pylint:disable=too-many-ancestors """ A Pop up menu to be triggered when right clicking on widgets that this menu has been applied to. @@ -72,7 +72,7 @@ def _select_all(self): self._widget.select_range(0, tk.END) -class RightClickMenu(tk.Menu): # pylint: disable=too-many-ancestors +class RightClickMenu(tk.Menu): # pylint:disable=too-many-ancestors """ A Pop up menu that can be bound to a right click mouse event to bring up a context menu Parameters @@ -118,7 +118,7 @@ def popup(self, event): self.tk_popup(event.x_root, event.y_root) -class ConsoleOut(ttk.Frame): # pylint: disable=too-many-ancestors +class ConsoleOut(ttk.Frame): # pylint:disable=too-many-ancestors """ The Console out section of the GUI. A Read only text box for displaying the output from stdout/stderr. @@ -195,7 +195,7 @@ def _redirect_console(self): sys.stderr = _SysOutRouter(self._console, "stderr") logger.debug("Redirected console") - def _clear(self, *args): # pylint: disable=unused-argument + def _clear(self, *args): # pylint:disable=unused-argument """ Clear the console output screen """ logger.debug("Clear console") if not self._console_clear.get(): @@ -206,7 +206,7 @@ def _clear(self, *args): # pylint: disable=unused-argument logger.debug("Cleared console") -class _ReadOnlyText(tk.Text): # pylint: disable=too-many-ancestors +class _ReadOnlyText(tk.Text): # pylint:disable=too-many-ancestors """ A read only text widget. Standard tkinter Text widgets are read/write by default. As we want to make the console @@ -417,7 +417,7 @@ def __call__(self, *args): return self.tk_call(self.orig_and_operation + args) -class StatusBar(ttk.Frame): # pylint: disable=too-many-ancestors +class StatusBar(ttk.Frame): # pylint:disable=too-many-ancestors """ Status Bar for displaying the Status Message and Progress Bar at the bottom of the GUI. Parameters @@ -725,7 +725,7 @@ def _hide(self): self._topwidget = None -class MultiOption(ttk.Checkbutton): # pylint: disable=too-many-ancestors +class MultiOption(ttk.Checkbutton): # pylint:disable=too-many-ancestors """ Similar to the standard :class:`ttk.Radio` widget, but with the ability to select multiple pre-defined options. Selected options are generated as `nargs` for the argument parser to consume. @@ -767,7 +767,7 @@ def _master_needs_update(self): logger.trace(retval) return retval - def _on_update(self, *args): # pylint: disable=unused-argument + def _on_update(self, *args): # pylint:disable=unused-argument """ Update the master variable on a check button change. The value for this checked option is added or removed from the :attr:`_master_variable` @@ -788,7 +788,7 @@ def _on_update(self, *args): # pylint: disable=unused-argument logger.trace("Setting master variable to: %s", val) self._master_variable.set(val) - def _on_master_update(self, *args): # pylint: disable=unused-argument + def _on_master_update(self, *args): # pylint:disable=unused-argument """ Update the check button on a master variable change (e.g. load .fsw file in the GUI). The value for this option is set to ``True`` or ``False`` depending on it's existence in diff --git a/lib/gui/display.py b/lib/gui/display.py index 0d2b107f93..3729e35437 100644 --- a/lib/gui/display.py +++ b/lib/gui/display.py @@ -23,7 +23,7 @@ _ = _LANG.gettext -class DisplayNotebook(ttk.Notebook): # pylint: disable=too-many-ancestors +class DisplayNotebook(ttk.Notebook): # pylint:disable=too-many-ancestors """ The tkinter Notebook that holds the display items. Parameters @@ -152,7 +152,7 @@ def _remove_tabs(self): child_object.close() # Call the OptionalDisplayPage close() method self.forget(child) - def _update_displaybook(self, *args): # pylint: disable=unused-argument + def _update_displaybook(self, *args): # pylint:disable=unused-argument """ Callback to be executed when the global tkinter variable `display` (:attr:`wrapper_var`) is updated when a Faceswap task is executed. diff --git a/lib/gui/display_analysis.py b/lib/gui/display_analysis.py index a04ec63843..9dcef89164 100644 --- a/lib/gui/display_analysis.py +++ b/lib/gui/display_analysis.py @@ -23,7 +23,7 @@ _ = _LANG.gettext -class Analysis(DisplayPage): # pylint: disable=too-many-ancestors +class Analysis(DisplayPage): # pylint:disable=too-many-ancestors """ Session Analysis Tab. The area of the GUI that holds the session summary stats for model training sessions. @@ -366,7 +366,7 @@ def _set_buttons_state(self, *args): # pylint:disable=unused-argument button.state([state]) -class StatsData(ttk.Frame): # pylint: disable=too-many-ancestors +class StatsData(ttk.Frame): # pylint:disable=too-many-ancestors """ Stats frame of analysis tab. Holds the tree-view containing the summarized session statistics in the Analysis tab. diff --git a/lib/gui/display_command.py b/lib/gui/display_command.py index ee2cd8231e..e7d59f2876 100644 --- a/lib/gui/display_command.py +++ b/lib/gui/display_command.py @@ -26,7 +26,7 @@ _ = _LANG.gettext -class PreviewExtract(DisplayOptionalPage): # pylint: disable=too-many-ancestors +class PreviewExtract(DisplayOptionalPage): # pylint:disable=too-many-ancestors """ Tab to display output preview images for extract and convert """ def __init__(self, *args, **kwargs) -> None: logger.debug(parse_class_init(locals())) @@ -80,7 +80,7 @@ def save_items(self) -> None: print(f"Saved preview to {filename}") -class PreviewTrain(DisplayOptionalPage): # pylint: disable=too-many-ancestors +class PreviewTrain(DisplayOptionalPage): # pylint:disable=too-many-ancestors """ Training preview image(s) """ def __init__(self, *args, **kwargs) -> None: logger.debug(parse_class_init(locals())) @@ -163,7 +163,7 @@ def save_items(self) -> None: self._display.save(location) -class GraphDisplay(DisplayOptionalPage): # pylint: disable=too-many-ancestors +class GraphDisplay(DisplayOptionalPage): # pylint:disable=too-many-ancestors """ The Graph Tab of the Display section """ def __init__(self, parent: ttk.Notebook, diff --git a/lib/gui/display_graph.py b/lib/gui/display_graph.py index 5ea61cad1d..c5f1304a81 100755 --- a/lib/gui/display_graph.py +++ b/lib/gui/display_graph.py @@ -29,7 +29,7 @@ logger: logging.Logger = logging.getLogger(__name__) -class GraphBase(ttk.Frame): # pylint: disable=too-many-ancestors +class GraphBase(ttk.Frame): # pylint:disable=too-many-ancestors """ Base class for matplotlib line graphs. Parameters @@ -321,7 +321,7 @@ def clear(self) -> None: del self._fig -class TrainingGraph(GraphBase): # pylint: disable=too-many-ancestors +class TrainingGraph(GraphBase): # pylint:disable=too-many-ancestors """ Live graph to be displayed during training. Parameters @@ -352,7 +352,7 @@ def build(self) -> None: self._plotcanvas.draw() logger.debug("Built training graph") - def refresh(self, *args) -> None: # pylint: disable=unused-argument + def refresh(self, *args) -> None: # pylint:disable=unused-argument """ Read the latest loss data and apply to current graph """ refresh_var = T.cast(tk.BooleanVar, get_config().tk_vars.refresh_graph) if not refresh_var.get() and self._thread is None: @@ -406,15 +406,15 @@ def save_fig(self, location: str) -> None: def _resize_fig(self) -> None: """ Resize the figure to the current canvas size. """ - class Event(): # pylint: disable=too-few-public-methods + class Event(): # pylint:disable=too-few-public-methods """ Event class that needs to be passed to plotcanvas.resize """ - pass # pylint: disable=unnecessary-pass + pass # pylint:disable=unnecessary-pass setattr(Event, "width", self.winfo_width()) setattr(Event, "height", self.winfo_height()) - self._plotcanvas.resize(Event) # pylint: disable=no-value-for-parameter + self._plotcanvas.resize(Event) # pylint:disable=no-value-for-parameter -class SessionGraph(GraphBase): # pylint: disable=too-many-ancestors +class SessionGraph(GraphBase): # pylint:disable=too-many-ancestors """ Session Graph for session pop-up. Parameters @@ -476,7 +476,7 @@ def set_yscale_type(self, scale: str) -> None: logger.debug("Updated scale type") -class NavigationToolbar(NavigationToolbar2Tk): # pylint: disable=too-many-ancestors +class NavigationToolbar(NavigationToolbar2Tk): # pylint:disable=too-many-ancestors """ Overrides the default Navigation Toolbar to provide only the buttons we require and to layout the items in a consistent manner with the rest of the GUI for the Analysis Session Graph pop up Window. @@ -493,7 +493,7 @@ class NavigationToolbar(NavigationToolbar2Tk): # pylint: disable=too-many-ances toolitems = [t for t in NavigationToolbar2Tk.toolitems if t[0] in ("Home", "Pan", "Zoom", "Save")] - def __init__(self, # pylint: disable=super-init-not-called + def __init__(self, # pylint:disable=super-init-not-called canvas: FigureCanvasTkAgg, window: ttk.Frame, *, diff --git a/lib/gui/display_page.py b/lib/gui/display_page.py index e6bc3eaef0..5602c22f52 100644 --- a/lib/gui/display_page.py +++ b/lib/gui/display_page.py @@ -16,7 +16,7 @@ _ = _LANG.gettext -class DisplayPage(ttk.Frame): # pylint: disable=too-many-ancestors +class DisplayPage(ttk.Frame): # pylint:disable=too-many-ancestors """ Parent frame holder for each tab. Defines uniform structure for each tab to inherit from """ def __init__(self, parent, tab_name, helptext): @@ -159,7 +159,7 @@ def subnotebook_page_from_id(self, tab_id): return self.subnotebook.children[tab_name] -class DisplayOptionalPage(DisplayPage): # pylint: disable=too-many-ancestors +class DisplayOptionalPage(DisplayPage): # pylint:disable=too-many-ancestors """ Parent Context Sensitive Display Tab """ def __init__(self, parent, tab_name, helptext, wait_time, command=None): diff --git a/lib/gui/menu.py b/lib/gui/menu.py index 7b83af56e6..460e08fd58 100644 --- a/lib/gui/menu.py +++ b/lib/gui/menu.py @@ -75,7 +75,7 @@ def __init__(self, parent: MainMenuBar) -> None: def _build(self) -> None: """ Add the settings menu to the menu bar """ - # pylint: disable=cell-var-from-loop + # pylint:disable=cell-var-from-loop logger.debug("Building settings menu") self.add_command(label=_("Configure Settings..."), underline=0, @@ -464,7 +464,7 @@ def _switch_branch(cls, branch: str) -> None: def _build_recources_menu(self) -> None: """ Build resources menu """ - # pylint: disable=cell-var-from-loop + # pylint:disable=cell-var-from-loop logger.debug("Building Resources Files menu") for resource in _RESOURCES: self.recources_menu.add_command( @@ -478,7 +478,7 @@ def _clear_console(cls) -> None: get_config().tk_vars.console_clear.set(True) -class TaskBar(ttk.Frame): # pylint: disable=too-many-ancestors +class TaskBar(ttk.Frame): # pylint:disable=too-many-ancestors """ Task bar buttons Parameters @@ -597,7 +597,7 @@ def _task_btns(self) -> None: def _settings_btns(self) -> None: """ Place the settings buttons """ - # pylint: disable=cell-var-from-loop + # pylint:disable=cell-var-from-loop frame = ttk.Frame(self._btn_frame) frame.pack(side=tk.LEFT, anchor=tk.W, expand=False, padx=2) for name in ("extract", "train", "convert"): diff --git a/lib/gui/popup_session.py b/lib/gui/popup_session.py index f145e37e52..6ba9e2b4a6 100644 --- a/lib/gui/popup_session.py +++ b/lib/gui/popup_session.py @@ -355,7 +355,7 @@ def _option_button_save(self) -> None: csvout.writerow(fieldnames) csvout.writerows(zip(*[save_data[key] for key in fieldnames])) - def _option_button_reload(self, *args) -> None: # pylint: disable=unused-argument + def _option_button_reload(self, *args) -> None: # pylint:disable=unused-argument """ Action for reset button press and checkbox changes. Parameters @@ -376,7 +376,7 @@ def _option_button_reload(self, *args) -> None: # pylint: disable=unused-argume self._vars.scale.get()) logger.debug("Refreshed Graph") - def _graph_scale(self, *args) -> None: # pylint: disable=unused-argument + def _graph_scale(self, *args) -> None: # pylint:disable=unused-argument """ Action for changing graph scale. Parameters diff --git a/lib/gui/project.py b/lib/gui/project.py index 4fd61de074..1ff6c6b2dc 100644 --- a/lib/gui/project.py +++ b/lib/gui/project.py @@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) -class _GuiSession(): # pylint:disable=too-few-public-methods +class _GuiSession(): """ Parent class for GUI Session Handlers. Parameters diff --git a/lib/gui/theme.py b/lib/gui/theme.py index 993a906fd6..1ea30f7e18 100644 --- a/lib/gui/theme.py +++ b/lib/gui/theme.py @@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) -class Style(): # pylint:disable=too-few-public-methods +class Style(): """ Set the overarching theme and customize widgets. Parameters @@ -439,7 +439,7 @@ def slider(self, key, control_color, active_color, trough_color): troughcolor=trough_color) -class _TkImage(): # pylint:disable=too-few-public-methods +class _TkImage(): """ Create a tk image for a given pattern and shape. """ def __init__(self): diff --git a/lib/gui/utils/config.py b/lib/gui/utils/config.py index 57bd42aa33..a0c2aa72f0 100644 --- a/lib/gui/utils/config.py +++ b/lib/gui/utils/config.py @@ -49,7 +49,7 @@ def initialize_config(root: tk.Tk, ``None`` if the config has already been initialized otherwise the global configuration options """ - global _CONFIG # pylint: disable=global-statement + global _CONFIG # pylint:disable=global-statement if _CONFIG is not None: return None logger.debug("Initializing config: (root: %s, cli_opts: %s, " diff --git a/lib/gui/utils/file_handler.py b/lib/gui/utils/file_handler.py index e1e687e1c6..4364eece3e 100644 --- a/lib/gui/utils/file_handler.py +++ b/lib/gui/utils/file_handler.py @@ -339,7 +339,7 @@ def _save_filename(self) -> str: return filedialog.asksaveasfilename(**self._kwargs) # type: ignore @staticmethod - def _nothing() -> None: # pylint: disable=useless-return + def _nothing() -> None: # pylint:disable=useless-return """ Method that does nothing, used for disabling open/save pop up. """ logger.debug("Popping Nothing browser") return diff --git a/lib/gui/utils/image.py b/lib/gui/utils/image.py index 592ee98f64..816ba19257 100644 --- a/lib/gui/utils/image.py +++ b/lib/gui/utils/image.py @@ -28,7 +28,7 @@ def initialize_images() -> None: This should only be called once on first GUI startup. Future access to :class:`Images` handler should only be executed through :func:`get_images`. """ - global _IMAGES # pylint: disable=global-statement + global _IMAGES # pylint:disable=global-statement if _IMAGES is not None: return logger.debug("Initializing images") diff --git a/lib/gui/utils/misc.py b/lib/gui/utils/misc.py index 58a4befa98..4d60c80214 100644 --- a/lib/gui/utils/misc.py +++ b/lib/gui/utils/misc.py @@ -71,7 +71,7 @@ def run(self) -> None: if self._target is not None: retval = self._target(*self._args, **self._kwargs) self._queue.put(retval) - except Exception: # pylint: disable=broad-except + except Exception: # pylint:disable=broad-except self.err = T.cast(tuple[type[BaseException], BaseException, "TracebackType"], sys.exc_info()) assert self.err is not None diff --git a/lib/gui/wrapper.py b/lib/gui/wrapper.py index 84fe5459e5..88ee11f646 100644 --- a/lib/gui/wrapper.py +++ b/lib/gui/wrapper.py @@ -18,7 +18,7 @@ from .utils import get_config, get_images, LongRunningTask, preview_trigger if os.name == "nt": - import win32console # pylint: disable=import-error + import win32console # pylint:disable=import-error logger = logging.getLogger(__name__) diff --git a/lib/image.py b/lib/image.py index 96685e6cb4..d351b1a23e 100644 --- a/lib/image.py +++ b/lib/image.py @@ -159,7 +159,7 @@ def _initialize(self, index=0): # noqa:C901 correct frame for all videos. Navigating to the previous keyframe then discarding frames until the correct frame is reached appears to work well. """ - # pylint: disable-all + # pylint:disable-all if self._read_gen is not None: self._read_gen.close() @@ -1567,7 +1567,7 @@ def _save(self, else: cv2.imwrite(filename, image) logger.trace("Saved image: '%s'", filename) # type:ignore - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint:disable=broad-except logger.error("Failed to save image '%s'. Original Error: %s", filename, str(err)) del image del filename diff --git a/lib/keras_utils.py b/lib/keras_utils.py index 9f27898620..af47a3e466 100644 --- a/lib/keras_utils.py +++ b/lib/keras_utils.py @@ -66,7 +66,7 @@ def replicate_pad(image: Tensor, padding: int) -> Tensor: return padded -class ColorSpaceConvert(): # pylint:disable=too-few-public-methods +class ColorSpaceConvert(): """ Transforms inputs between different color spaces on the GPU Notes diff --git a/lib/keypress.py b/lib/keypress.py index 98d1872005..439d1d2253 100644 --- a/lib/keypress.py +++ b/lib/keypress.py @@ -21,7 +21,7 @@ # Windows if os.name == "nt": - import msvcrt # pylint: disable=import-error + import msvcrt # pylint:disable=import-error # Posix (Linux, OS X) else: diff --git a/lib/model/autoclip.py b/lib/model/autoclip.py index a9ccfe888d..826959d66b 100644 --- a/lib/model/autoclip.py +++ b/lib/model/autoclip.py @@ -3,7 +3,7 @@ import tensorflow as tf -class AutoClipper(): # pylint:disable=too-few-public-methods +class AutoClipper(): """ AutoClip: Adaptive Gradient Clipping for Source Separation Networks Parameters diff --git a/lib/model/layers.py b/lib/model/layers.py index 6569625877..4f2c9824c6 100644 --- a/lib/model/layers.py +++ b/lib/model/layers.py @@ -617,7 +617,7 @@ def build(self, input_shape: tuple[int, ...]) -> None: Keras tensor (future input to layer) or ``list``/``tuple`` of Keras tensors to reference for weight shape computations. """ - pass # pylint: disable=unnecessary-pass + pass # pylint:disable=unnecessary-pass def call(self, inputs: tf.Tensor, *args, **kwargs) -> tf.Tensor: """This is where the layer's logic lives. diff --git a/lib/model/losses/feature_loss.py b/lib/model/losses/feature_loss.py index 83ba174c28..a23060f3e5 100644 --- a/lib/model/losses/feature_loss.py +++ b/lib/model/losses/feature_loss.py @@ -48,7 +48,7 @@ class NetInfo: outputs: list[Layer] = field(default_factory=list) -class _LPIPSTrunkNet(): # pylint:disable=too-few-public-methods +class _LPIPSTrunkNet(): """ Trunk neural network loader for LPIPS Loss function. Parameters @@ -145,7 +145,7 @@ def __call__(self) -> Model: return model -class _LPIPSLinearNet(_LPIPSTrunkNet): # pylint:disable=too-few-public-methods +class _LPIPSLinearNet(_LPIPSTrunkNet): """ The Linear Network to be applied to the difference between the true and predicted outputs of the trunk network. @@ -232,7 +232,7 @@ def __call__(self) -> Model: return model -class LPIPSLoss(): # pylint:disable=too-few-public-methods +class LPIPSLoss(): """ LPIPS Loss Function. A perceptual loss function that uses linear outputs from pretrained CNNs feature layers. diff --git a/lib/model/networks/simple_nets.py b/lib/model/networks/simple_nets.py index 4fa8294d15..727161bcd8 100644 --- a/lib/model/networks/simple_nets.py +++ b/lib/model/networks/simple_nets.py @@ -40,7 +40,7 @@ def __init__(self, logger.debug("Initialized: %s", self.__class__.__name__) -class AlexNet(_net): # pylint:disable=too-few-public-methods +class AlexNet(_net): """ AlexNet ported from torchvision version. Notes @@ -136,7 +136,7 @@ def __call__(self) -> tf.keras.models.Model: return Model(inputs=inputs, outputs=[var_x]) -class SqueezeNet(_net): # pylint:disable=too-few-public-methods +class SqueezeNet(_net): """ SqueezeNet ported from torchvision version. Notes diff --git a/lib/multithreading.py b/lib/multithreading.py index 73cdc983ee..a2c4300d44 100644 --- a/lib/multithreading.py +++ b/lib/multithreading.py @@ -98,7 +98,7 @@ def run(self) -> None: try: if self._target is not None: self._target(*self._args, **self._kwargs) - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint:disable=broad-except self.err = sys.exc_info() logger.debug("Error in thread (%s): %s", self._name, str(err)) finally: @@ -216,11 +216,11 @@ def join(self) -> None: """ logger.debug("Joining Threads: '%s'", self._name) for thread in self._threads: - logger.debug("Joining Thread: '%s'", thread._name) # pylint: disable=protected-access + logger.debug("Joining Thread: '%s'", thread._name) # pylint:disable=protected-access thread.join() if thread.err: logger.error("Caught exception in thread: '%s'", - thread._name) # pylint: disable=protected-access + thread._name) # pylint:disable=protected-access raise thread.err[1].with_traceback(thread.err[2]) del self._threads self._threads = [] diff --git a/lib/queue_manager.py b/lib/queue_manager.py index 6848636bd1..9fd5122aa4 100644 --- a/lib/queue_manager.py +++ b/lib/queue_manager.py @@ -7,7 +7,7 @@ import logging import threading -from queue import Queue, Empty as QueueEmpty # pylint: disable=unused-import; # noqa +from queue import Queue, Empty as QueueEmpty # pylint:disable=unused-import; # noqa from time import sleep logger = logging.getLogger(__name__) @@ -174,4 +174,4 @@ def _debug_queue_sizes(self, update_interval) -> None: sleep(update_interval) -queue_manager = _QueueManager() # pylint: disable=invalid-name +queue_manager = _QueueManager() # pylint:disable=invalid-name diff --git a/lib/serializer.py b/lib/serializer.py index a468a4401d..ab48ec129f 100644 --- a/lib/serializer.py +++ b/lib/serializer.py @@ -252,13 +252,13 @@ def __init__(self): def _marshal(self, data): """ Pickle and compress data """ - data = self._child._marshal(data) # pylint: disable=protected-access + data = self._child._marshal(data) # pylint:disable=protected-access return zlib.compress(data) def _unmarshal(self, data): """ Decompress and unpicke data """ data = zlib.decompress(data) - return self._child._unmarshal(data) # pylint: disable=protected-access + return self._child._unmarshal(data) # pylint:disable=protected-access def get_serializer(serializer): diff --git a/lib/sysinfo.py b/lib/sysinfo.py index fa0e2f984a..7eda070361 100644 --- a/lib/sysinfo.py +++ b/lib/sysinfo.py @@ -17,7 +17,7 @@ from setup import CudaCheck -class _SysInfo(): # pylint:disable=too-few-public-methods +class _SysInfo(): """ Obtain information about the System, Python and GPU """ def __init__(self) -> None: self._state_file = _State().state_file @@ -251,7 +251,7 @@ def get_sysinfo() -> str: """ try: retval = _SysInfo().full_info() - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint:disable=broad-except retval = f"Exception occured trying to retrieve sysinfo: {str(err)}" raise return retval @@ -420,4 +420,4 @@ def _get_state_file(self) -> str: return retval -sysinfo = get_sysinfo() # pylint: disable=invalid-name +sysinfo = get_sysinfo() # pylint:disable=invalid-name diff --git a/lib/training/augmentation.py b/lib/training/augmentation.py index 81f56e8fed..f9edf2a558 100644 --- a/lib/training/augmentation.py +++ b/lib/training/augmentation.py @@ -200,7 +200,7 @@ def _random_clahe(self, batch: np.ndarray) -> None: grid_sizes = (grid_bases * (base_contrast // 2)) + base_contrast logger.trace("Adjusting Contrast. Grid Sizes: %s", grid_sizes) # type: ignore - clahes = [cv2.createCLAHE(clipLimit=2.0, # pylint: disable=no-member + clahes = [cv2.createCLAHE(clipLimit=2.0, # pylint:disable=no-member tileGridSize=(grid_size, grid_size)) for grid_size in grid_sizes] diff --git a/lib/training/cache.py b/lib/training/cache.py index a2fa1d28d4..9813199949 100644 --- a/lib/training/cache.py +++ b/lib/training/cache.py @@ -475,7 +475,7 @@ def _get_localized_mask(self, return mask -class RingBuffer(): # pylint: disable=too-few-public-methods +class RingBuffer(): """ Rolling buffer for holding training/preview batches Parameters diff --git a/lib/training/generator.py b/lib/training/generator.py index 455e96f11e..538941adf0 100644 --- a/lib/training/generator.py +++ b/lib/training/generator.py @@ -390,7 +390,7 @@ def _to_float32(self, in_array: np.ndarray) -> np.ndarray: casting="unsafe") -class TrainingDataGenerator(DataGenerator): # pylint:disable=too-few-public-methods +class TrainingDataGenerator(DataGenerator): """ A Training Data Generator for compiling data for feeding to a model. This class is called from :mod:`plugins.train.trainer._base` and launches a background diff --git a/lib/training/lr_finder.py b/lib/training/lr_finder.py index 62e2eff5c3..d7c3298c69 100644 --- a/lib/training/lr_finder.py +++ b/lib/training/lr_finder.py @@ -32,7 +32,7 @@ class LRStrength(Enum): EXTREME = 2.5 -class LearningRateFinder: # pylint:disable=too-few-public-methods +class LearningRateFinder: """ Learning Rate Finder Parameters diff --git a/lib/training/preview_tk.py b/lib/training/preview_tk.py index a22fd3c0b9..633ead57e6 100644 --- a/lib/training/preview_tk.py +++ b/lib/training/preview_tk.py @@ -133,7 +133,7 @@ def _add_scale_combo(self) -> ttk.Combobox: logger.debug("Added scale combo: '%s'", scale) return scale - def _clear_combo_focus(self, *args) -> None: # pylint: disable=unused-argument + def _clear_combo_focus(self, *args) -> None: # pylint:disable=unused-argument """ Remove the highlighting and stealing of focus that the combobox annoyingly implements. """ logger.debug("Clearing scale combo focus") @@ -316,7 +316,7 @@ def _configure_scrollbars(self, frame: tk.Frame) -> None: self.configure(xscrollcommand=x_scrollbar.set, yscrollcommand=y_scrollbar.set) logger.debug("Configured scrollbars. x: '%s', y: '%s'", x_scrollbar, y_scrollbar) - def _resize(self, event: tk.Event) -> None: # pylint: disable=unused-argument + def _resize(self, event: tk.Event) -> None: # pylint:disable=unused-argument """ Place the image in center of canvas on resize event and move to top left Parameters @@ -518,7 +518,7 @@ def save_preview(self, *args) -> None: self._save_var.set(False) -class _Bindings(): # pylint: disable=too-few-public-methods +class _Bindings(): # pylint:disable=too-few-public-methods """ Handle Mouse and Keyboard bindings for the canvas. Parameters @@ -654,7 +654,7 @@ def _set_key_bindings(self, is_standalone: bool) -> None: logger.debug("Bound key events") -class PreviewTk(PreviewBase): # pylint:disable=too-few-public-methods +class PreviewTk(PreviewBase): """ Holds a preview window for displaying the pop out preview. Parameters diff --git a/lib/utils.py b/lib/utils.py index a81000e681..d4018b5986 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -506,7 +506,7 @@ class FaceswapError(Exception): pass # pylint:disable=unnecessary-pass -class GetModel(): # pylint:disable=too-few-public-methods +class GetModel(): """ Check for models in the cache path. If available, return the path, if not available, get, unzip and install model diff --git a/plugins/convert/color/color_transfer.py b/plugins/convert/color/color_transfer.py index 2425d9bfb5..4b8080a433 100644 --- a/plugins/convert/color/color_transfer.py +++ b/plugins/convert/color/color_transfer.py @@ -70,12 +70,12 @@ def process(self, old_face, new_face, raw_mask): # convert the images from the RGB to L*ab* color space, being # sure to utilizing the floating point data type (note: OpenCV # expects floats to be 32-bit, so use that instead of 64-bit) - source = cv2.cvtColor( # pylint: disable=no-member + source = cv2.cvtColor( # pylint:disable=no-member np.rint(old_face * raw_mask * 255.0).astype("uint8"), - cv2.COLOR_BGR2LAB).astype("float32") # pylint: disable=no-member - target = cv2.cvtColor( # pylint: disable=no-member + cv2.COLOR_BGR2LAB).astype("float32") # pylint:disable=no-member + target = cv2.cvtColor( # pylint:disable=no-member np.rint(new_face * raw_mask * 255.0).astype("uint8"), - cv2.COLOR_BGR2LAB).astype("float32") # pylint: disable=no-member + cv2.COLOR_BGR2LAB).astype("float32") # pylint:disable=no-member # compute color statistics for the source and target images (l_mean_src, l_std_src, a_mean_src, a_std_src, @@ -85,7 +85,7 @@ def process(self, old_face, new_face, raw_mask): b_mean_tar, b_std_tar) = self.image_stats(target) # subtract the means from the target image - (light, col_a, col_b) = cv2.split(target) # pylint: disable=no-member + (light, col_a, col_b) = cv2.split(target) # pylint:disable=no-member light -= l_mean_tar col_a -= a_mean_tar col_b -= b_mean_tar @@ -115,10 +115,10 @@ def process(self, old_face, new_face, raw_mask): # merge the channels together and convert back to the RGB color # space, being sure to utilize the 8-bit unsigned integer data # type - transfer = cv2.merge([light, col_a, col_b]) # pylint: disable=no-member - transfer = cv2.cvtColor( # pylint: disable=no-member + transfer = cv2.merge([light, col_a, col_b]) # pylint:disable=no-member + transfer = cv2.cvtColor( # pylint:disable=no-member transfer.astype("uint8"), - cv2.COLOR_LAB2BGR).astype("float32") / 255.0 # pylint: disable=no-member + cv2.COLOR_LAB2BGR).astype("float32") / 255.0 # pylint:disable=no-member background = new_face * (1 - raw_mask) merged = transfer + background # return the color transferred image @@ -139,7 +139,7 @@ def image_stats(image): channels, respectively """ # compute the mean and standard deviation of each channel - (light, col_a, col_b) = cv2.split(image) # pylint: disable=no-member + (light, col_a, col_b) = cv2.split(image) # pylint:disable=no-member (l_mean, l_std) = (light.mean(), light.std()) (a_mean, a_std) = (col_a.mean(), col_a.std()) (b_mean, b_std) = (col_b.mean(), col_b.std()) diff --git a/plugins/convert/color/manual_balance.py b/plugins/convert/color/manual_balance.py index dfd0ceb199..7dc6950bb6 100644 --- a/plugins/convert/color/manual_balance.py +++ b/plugins/convert/color/manual_balance.py @@ -44,6 +44,6 @@ def convert_colorspace(self, new_face, to_bgr=False): mode = self.config["colorspace"].lower() colorspace = "YCrCb" if mode == "ycrcb" else mode.upper() conversion = f"{colorspace}2BGR" if to_bgr else f"BGR2{colorspace}" - image = cv2.cvtColor(new_face.astype("uint8"), # pylint: disable=no-member + image = cv2.cvtColor(new_face.astype("uint8"), # pylint:disable=no-member getattr(cv2, f"COLOR_{conversion}")).astype("float32") / 255.0 return image diff --git a/plugins/convert/color/seamless_clone.py b/plugins/convert/color/seamless_clone.py index 09e8bc73de..dc2f1fe21d 100644 --- a/plugins/convert/color/seamless_clone.py +++ b/plugins/convert/color/seamless_clone.py @@ -34,11 +34,11 @@ def process(self, old_face, new_face, raw_mask): ((height, height), (width, width), (0, 0)), 'constant')).astype("uint8") - blended = cv2.seamlessClone(insertion, # pylint: disable=no-member + blended = cv2.seamlessClone(insertion, # pylint:disable=no-member prior, insertion_mask, (x_center, y_center), - cv2.NORMAL_CLONE) # pylint: disable=no-member + cv2.NORMAL_CLONE) # pylint:disable=no-member blended = blended[height:-height, width:-width] return blended.astype("float32") / 255.0 diff --git a/plugins/convert/scaling/sharpen.py b/plugins/convert/scaling/sharpen.py index 1ecca3faad..0179de9fd6 100644 --- a/plugins/convert/scaling/sharpen.py +++ b/plugins/convert/scaling/sharpen.py @@ -34,15 +34,15 @@ def box(new_face, kernel_center, amount): kernel[center, center] = 1.0 box_filter = np.ones(kernel_size, dtype="float32") / kernel_size[0]**2 kernel = kernel + (kernel - box_filter) * amount - new_face = cv2.filter2D(new_face, -1, kernel) # pylint: disable=no-member + new_face = cv2.filter2D(new_face, -1, kernel) # pylint:disable=no-member return new_face @staticmethod def gaussian(new_face, kernel_center, amount): """ Sharpen using gaussian filter """ kernel_size = kernel_center[0] - blur = cv2.GaussianBlur(new_face, kernel_size, 0) # pylint: disable=no-member - new_face = cv2.addWeighted(new_face, # pylint: disable=no-member + blur = cv2.GaussianBlur(new_face, kernel_size, 0) # pylint:disable=no-member + new_face = cv2.addWeighted(new_face, # pylint:disable=no-member 1.0 + (0.5 * amount), blur, -(0.5 * amount), @@ -53,7 +53,7 @@ def unsharp_mask(self, new_face, kernel_center, amount): """ Sharpen using unsharp mask """ kernel_size = kernel_center[0] threshold = self.config["threshold"] / 255.0 - blur = cv2.GaussianBlur(new_face, kernel_size, 0) # pylint: disable=no-member + blur = cv2.GaussianBlur(new_face, kernel_size, 0) # pylint:disable=no-member low_contrast_mask = (abs(new_face - blur) < threshold).astype("float32") sharpened = (new_face * (1.0 + amount)) + (blur * -amount) new_face = (new_face * (1.0 - low_contrast_mask)) + (sharpened * low_contrast_mask) diff --git a/plugins/convert/writer/_base.py b/plugins/convert/writer/_base.py index 33389f7989..a67ebee28e 100644 --- a/plugins/convert/writer/_base.py +++ b/plugins/convert/writer/_base.py @@ -166,7 +166,7 @@ def write(self, filename: str, image: T.Any) -> None: """ raise NotImplementedError - def pre_encode(self, image: np.ndarray, **kwargs) -> T.Any: # pylint: disable=unused-argument + def pre_encode(self, image: np.ndarray, **kwargs) -> T.Any: # pylint:disable=unused-argument """ Some writer plugins support the pre-encoding of images prior to saving out. As patching is done in multiple threads, but writing is done in a single thread, it can speed up the process to do any pre-encoding as part of the converter process. diff --git a/plugins/convert/writer/gif.py b/plugins/convert/writer/gif.py index eb5e0d2752..7a75ec93f3 100644 --- a/plugins/convert/writer/gif.py +++ b/plugins/convert/writer/gif.py @@ -82,7 +82,7 @@ def write(self, filename: str, image) -> None: self._set_dimensions(image.shape[:2]) self._writer = self._get_writer() if (image.shape[1], image.shape[0]) != self._output_dimensions: - image = cv2.resize(image, self._output_dimensions) # pylint: disable=no-member + image = cv2.resize(image, self._output_dimensions) # pylint:disable=no-member self.cache_frame(filename, image) self._save_from_cache() diff --git a/plugins/convert/writer/opencv.py b/plugins/convert/writer/opencv.py index caf5287eb9..17b025bfd9 100644 --- a/plugins/convert/writer/opencv.py +++ b/plugins/convert/writer/opencv.py @@ -72,7 +72,7 @@ def write(self, filename: str, image: list[bytes]) -> None: try: with open(fname, "wb") as outfile: outfile.write(img) - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint:disable=broad-except logger.error("Failed to save image '%s'. Original Error: %s", filename, err) def pre_encode(self, image: np.ndarray, **kwargs) -> list[bytes]: diff --git a/plugins/convert/writer/patch.py b/plugins/convert/writer/patch.py index da07279340..5f569677f5 100644 --- a/plugins/convert/writer/patch.py +++ b/plugins/convert/writer/patch.py @@ -142,7 +142,7 @@ def write(self, filename: str, image: list[list[bytes]]) -> None: try: with open(fname, "wb") as outfile: outfile.write(img) - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint:disable=broad-except logger.error("Failed to save image '%s'. Original Error: %s", filename, err) if not self.config["json_output"]: continue diff --git a/plugins/convert/writer/pillow.py b/plugins/convert/writer/pillow.py index 751e5675a9..a0bf113f62 100644 --- a/plugins/convert/writer/pillow.py +++ b/plugins/convert/writer/pillow.py @@ -75,7 +75,7 @@ def write(self, filename: str, image: list[BytesIO]) -> None: for fname, img in zip(filenames, image): with open(fname, "wb") as outfile: outfile.write(img.read()) - except Exception as err: # pylint: disable=broad-except + except Exception as err: # pylint:disable=broad-except logger.error("Failed to save image '%s'. Original Error: %s", filename, err) def pre_encode(self, image: np.ndarray, **kwargs) -> list[BytesIO]: diff --git a/plugins/extract/align/cv2_dnn.py b/plugins/extract/align/cv2_dnn.py index 44c41fb62a..0b9bc16824 100644 --- a/plugins/extract/align/cv2_dnn.py +++ b/plugins/extract/align/cv2_dnn.py @@ -56,8 +56,8 @@ def __init__(self, **kwargs) -> None: def init_model(self) -> None: """ Initialize CV2 DNN Detector Model""" - self.model = cv2.dnn.readNetFromTensorflow(self.model_path) # pylint: disable=no-member - self.model.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU) # pylint: disable=no-member + self.model = cv2.dnn.readNetFromTensorflow(self.model_path) # pylint:disable=no-member + self.model.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU) # pylint:disable=no-member def faces_to_feed(self, faces: np.ndarray) -> np.ndarray: """ Convert a batch of face images from UINT8 (0-255) to fp32 (0.0-255.0) diff --git a/plugins/extract/detect/cv2_dnn.py b/plugins/extract/detect/cv2_dnn.py index fd3e39142c..8d78747b80 100644 --- a/plugins/extract/detect/cv2_dnn.py +++ b/plugins/extract/detect/cv2_dnn.py @@ -26,14 +26,14 @@ def __init__(self, **kwargs) -> None: def init_model(self) -> None: """ Initialize CV2 DNN Detector Model""" assert isinstance(self.model_path, list) - self.model = cv2.dnn.readNetFromCaffe(self.model_path[1], # pylint: disable=no-member + self.model = cv2.dnn.readNetFromCaffe(self.model_path[1], # pylint:disable=no-member self.model_path[0]) - self.model.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU) # pylint: disable=no-member + self.model.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU) # pylint:disable=no-member def process_input(self, batch: BatchType) -> None: """ Compile the detection image(s) for prediction """ assert isinstance(batch, DetectorBatch) - batch.feed = cv2.dnn.blobFromImages(batch.image, # pylint: disable=no-member + batch.feed = cv2.dnn.blobFromImages(batch.image, # pylint:disable=no-member scalefactor=1.0, size=(self.input_size, self.input_size), mean=[104, 117, 123], diff --git a/plugins/extract/detect/mtcnn.py b/plugins/extract/detect/mtcnn.py index 8af8a41bef..78859ca249 100644 --- a/plugins/extract/detect/mtcnn.py +++ b/plugins/extract/detect/mtcnn.py @@ -596,7 +596,7 @@ def _filter_face_48net(self, class_probabilities: np.ndarray, return np.concatenate([results[..., :4], scores[..., None]], axis=-1), results[..., 4:].T -class MTCNN(): # pylint: disable=too-few-public-methods +class MTCNN(): # pylint:disable=too-few-public-methods """ MTCNN Detector for face alignment Parameters diff --git a/plugins/extract/mask/_base.py b/plugins/extract/mask/_base.py index 82a6e074f8..0284a604fb 100644 --- a/plugins/extract/mask/_base.py +++ b/plugins/extract/mask/_base.py @@ -283,7 +283,7 @@ def _resize(cls, image: np.ndarray, target_size: int) -> np.ndarray: scale = target_size / image_size if scale == 1.: return image - method = cv2.INTER_CUBIC if scale > 1. else cv2.INTER_AREA # pylint: disable=no-member + method = cv2.INTER_CUBIC if scale > 1. else cv2.INTER_AREA # pylint:disable=no-member resized = cv2.resize(image, (0, 0), fx=scale, fy=scale, interpolation=method) resized = resized if channels > 1 else resized[..., None] return resized diff --git a/plugins/extract/recognition/vgg_face2.py b/plugins/extract/recognition/vgg_face2.py index aa25a4efa3..acf268bfd4 100644 --- a/plugins/extract/recognition/vgg_face2.py +++ b/plugins/extract/recognition/vgg_face2.py @@ -99,7 +99,7 @@ def process_output(self, batch: BatchType) -> None: return -class Cluster(): # pylint: disable=too-few-public-methods +class Cluster(): # pylint:disable=too-few-public-methods """ Cluster the outputs from a VGG-Face 2 Model Parameters diff --git a/plugins/train/_config.py b/plugins/train/_config.py index 404e0d8e06..1a354d928c 100644 --- a/plugins/train/_config.py +++ b/plugins/train/_config.py @@ -101,7 +101,7 @@ class Config(FaceswapConfig): """ Config File for Models """ - # pylint: disable=too-many-statements + # pylint:disable=too-many-statements def set_defaults(self) -> None: """ Set the default values for config """ logger.debug("Setting defaults") diff --git a/plugins/train/model/_base/model.py b/plugins/train/model/_base/model.py index c3c448d665..5bc1161b17 100644 --- a/plugins/train/model/_base/model.py +++ b/plugins/train/model/_base/model.py @@ -140,7 +140,7 @@ def io(self) -> IO: # pylint:disable=invalid-name def config(self) -> dict: """ dict: The configuration dictionary for current plugin, as set by the user's configuration settings. """ - global _CONFIG # pylint: disable=global-statement + global _CONFIG # pylint:disable=global-statement if not _CONFIG: model_name = self._config_section logger.debug("Loading config for: %s", model_name) @@ -200,7 +200,7 @@ def state(self) -> "State": def _load_config(self) -> None: """ Load the global config for reference in :attr:`config` and set the faceswap blocks configuration options in `lib.model.nn_blocks` """ - global _CONFIG # pylint: disable=global-statement + global _CONFIG # pylint:disable=global-statement if not _CONFIG: model_name = self._config_section logger.debug("Loading config for: %s", model_name) @@ -645,7 +645,7 @@ def _replace_config(self, config_changeable_items) -> None: Configuration options that can be altered when resuming a model, and their current values """ - global _CONFIG # pylint: disable=global-statement + global _CONFIG # pylint:disable=global-statement if _CONFIG is None: return legacy_update = self._update_legacy_config() diff --git a/plugins/train/model/phaze_a.py b/plugins/train/model/phaze_a.py index 28c0f31a69..d6169fe252 100644 --- a/plugins/train/model/phaze_a.py +++ b/plugins/train/model/phaze_a.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ Phaze-A Model by TorzDF with thanks to BirbFakes and the myriad of testers. """ -# pylint: disable=too-many-lines +# pylint:disable=too-many-lines from __future__ import annotations import logging import typing as T @@ -979,7 +979,7 @@ def __call__(self) -> tf.keras.models.Model: return keras.models.Model(input_, var_x, name=f"fc_{self._side}") -class UpscaleBlocks(): # pylint: disable=too-few-public-methods +class UpscaleBlocks(): # pylint:disable=too-few-public-methods """ Obtain a block of upscalers. This class exists outside of the :class:`Decoder` model, as it is possible to place some of diff --git a/scripts/convert.py b/scripts/convert.py index a5b11da59a..72829cba87 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -515,7 +515,7 @@ def _start_thread(self, task: T.Literal["load", "save"]) -> None: logger.debug("Started thread: '%s'", task) # Loading tasks - def _load(self, *args) -> None: # pylint: disable=unused-argument + def _load(self, *args) -> None: # pylint:disable=unused-argument """ Load frames from disk. In a background thread: diff --git a/scripts/fsmedia.py b/scripts/fsmedia.py index 0663a58349..4bfd9a8a0b 100644 --- a/scripts/fsmedia.py +++ b/scripts/fsmedia.py @@ -428,7 +428,7 @@ def do_actions(self, extract_media: ExtractMedia) -> None: action.process(extract_media) -class PostProcessAction(): # pylint: disable=too-few-public-methods +class PostProcessAction(): # pylint:disable=too-few-public-methods """ Parent class for Post Processing Actions. Usable in Extract or Convert or both depending on context. Any post-processing actions should @@ -465,7 +465,7 @@ def process(self, extract_media: ExtractMedia) -> None: raise NotImplementedError -class DebugLandmarks(PostProcessAction): # pylint: disable=too-few-public-methods +class DebugLandmarks(PostProcessAction): # pylint:disable=too-few-public-methods """ Draw debug landmarks on face output. Extract Only """ def __init__(self, *args, **kwargs) -> None: super().__init__(self, *args, **kwargs) diff --git a/scripts/gui.py b/scripts/gui.py index 4417458ea9..b79cf30b31 100644 --- a/scripts/gui.py +++ b/scripts/gui.py @@ -133,7 +133,7 @@ def rebuild(self): self._last_session.from_dict(session_state) logger.debug("GUI Redrawn") - def close_app(self, *args): # pylint: disable=unused-argument + def close_app(self, *args): # pylint:disable=unused-argument """ Close Python. This is here because the graph animation function continues to run even when tkinter has gone away """ @@ -173,7 +173,7 @@ def _confirm_close_on_running_task(self): return True -class Gui(): # pylint: disable=too-few-public-methods +class Gui(): # pylint:disable=too-few-public-methods """ The GUI process. """ def __init__(self, arguments): self.root = FaceswapGui(arguments.debug) diff --git a/scripts/train.py b/scripts/train.py index 1adca528ec..66c271dd0b 100644 --- a/scripts/train.py +++ b/scripts/train.py @@ -499,13 +499,13 @@ def _show(self, image: np.ndarray, name: str = "") -> None: logger.debug("Saving preview to disk") img = "training_preview.png" imgfile = os.path.join(scriptpath, img) - cv2.imwrite(imgfile, image) # pylint: disable=no-member + cv2.imwrite(imgfile, image) # pylint:disable=no-member logger.debug("Saved preview to: '%s'", img) if self._args.redirect_gui: logger.debug("Generating preview for GUI") img = TRAININGPREVIEW imgfile = os.path.join(scriptpath, "lib", "gui", ".cache", "preview", img) - cv2.imwrite(imgfile, image) # pylint: disable=no-member + cv2.imwrite(imgfile, image) # pylint:disable=no-member logger.debug("Generated preview for GUI: '%s'", imgfile) if self._args.preview: logger.debug("Generating preview for display: '%s'", name) diff --git a/setup.py b/setup.py index 3f4c29cb7e..a7a86fe1e4 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ Install packages for faceswap.py """ -# pylint: disable=too-many-lines +# pylint:disable=too-many-lines import logging import ctypes @@ -1434,7 +1434,7 @@ def _seen_line_log(self, text: str) -> None: self._seen_lines.add(text) -class PexpectInstaller(Installer): # pylint: disable=too-few-public-methods +class PexpectInstaller(Installer): # pylint:disable=too-few-public-methods """ Package installer for Linux/macOS using Pexpect Uses Pexpect for installing packages allowing access to realtime feedback @@ -1472,7 +1472,7 @@ def call(self) -> int: return proc.exitstatus -class WinPTYInstaller(Installer): # pylint: disable=too-few-public-methods +class WinPTYInstaller(Installer): # pylint:disable=too-few-public-methods """ Package installer for Windows using WinPTY Spawns a pseudo PTY for installing packages allowing access to realtime feedback diff --git a/tools/alignments/media.py b/tools/alignments/media.py index 9fafdf0a21..da59992fcd 100644 --- a/tools/alignments/media.py +++ b/tools/alignments/media.py @@ -136,7 +136,7 @@ def check_input_folder(self) -> cv2.VideoCapture | None: os.path.isfile(self.folder) and os.path.splitext(self.folder)[1].lower() in _video_extensions): logger.verbose("Video exists at: '%s'", self.folder) # type: ignore - retval = cv2.VideoCapture(self.folder) # pylint: disable=no-member + retval = cv2.VideoCapture(self.folder) # pylint:disable=no-member # TODO ImageIO single frame seek seems slow. Look into this # retval = imageio.get_reader(self.folder, "ffmpeg") else: @@ -203,7 +203,7 @@ def load_video_frame(self, filename: str) -> np.ndarray: frame = os.path.splitext(filename)[0] logger.trace("Loading video frame: '%s'", frame) # type: ignore frame_no = int(frame[frame.rfind("_") + 1:]) - 1 - self._vid_reader.set(cv2.CAP_PROP_POS_FRAMES, frame_no) # pylint: disable=no-member + self._vid_reader.set(cv2.CAP_PROP_POS_FRAMES, frame_no) # pylint:disable=no-member _, image = self._vid_reader.read() # TODO imageio single frame seek seems slow. Look into this @@ -250,7 +250,7 @@ def save_image(output_folder: str, with open(output_file, "wb") as out_file: out_file.write(encoded_image) else: - cv2.imwrite(output_file, image) # pylint: disable=no-member + cv2.imwrite(output_file, image) # pylint:disable=no-member class Faces(MediaLoader): diff --git a/tools/manual/faceviewer/frame.py b/tools/manual/faceviewer/frame.py index f1443d9b20..f2f77ea39b 100644 --- a/tools/manual/faceviewer/frame.py +++ b/tools/manual/faceviewer/frame.py @@ -83,7 +83,7 @@ def _on_scroll(self, *event): self._canvas.yview(*event) self._canvas.viewport.update() - def _update_viewport(self, event): # pylint: disable=unused-argument + def _update_viewport(self, event): # pylint:disable=unused-argument """ Update the faces viewport and scrollbar. Parameters diff --git a/tools/manual/frameviewer/editor/_base.py b/tools/manual/frameviewer/editor/_base.py index 3e5bf81b5e..c4e9ebb6bf 100644 --- a/tools/manual/frameviewer/editor/_base.py +++ b/tools/manual/frameviewer/editor/_base.py @@ -389,7 +389,7 @@ def bind_mouse_motion(self): """ self._canvas.bind("", self._update_cursor) - def _update_cursor(self, event): # pylint: disable=unused-argument + def _update_cursor(self, event): # pylint:disable=unused-argument """ The mouse cursor display as bound to the mouse's event.. The default is to always return a standard cursor, so this method should be overridden for diff --git a/tools/manual/frameviewer/editor/bounding_box.py b/tools/manual/frameviewer/editor/bounding_box.py index 9eeef016fe..f3bbd78d00 100644 --- a/tools/manual/frameviewer/editor/bounding_box.py +++ b/tools/manual/frameviewer/editor/bounding_box.py @@ -291,7 +291,7 @@ def _drag_start(self, event): self._update_cursor(event) self._drag_start(event) - def _drag_stop(self, event): # pylint: disable=unused-argument + def _drag_stop(self, event): # pylint:disable=unused-argument """ Trigger a viewport thumbnail update on click + drag release Parameters diff --git a/tools/manual/frameviewer/editor/extract_box.py b/tools/manual/frameviewer/editor/extract_box.py index eb739545a2..f49acc055b 100644 --- a/tools/manual/frameviewer/editor/extract_box.py +++ b/tools/manual/frameviewer/editor/extract_box.py @@ -229,7 +229,7 @@ def _drag_start(self, event): callback = dict(anchor=self._resize, rotate=self._rotate, box=self._move) self._drag_callback = callback[self._mouse_location[0]] - def _drag_stop(self, event): # pylint: disable=unused-argument + def _drag_stop(self, event): # pylint:disable=unused-argument """ Trigger a viewport thumbnail update on click + drag release Parameters diff --git a/tools/manual/frameviewer/editor/landmarks.py b/tools/manual/frameviewer/editor/landmarks.py index bc2896212d..49c9c17d86 100644 --- a/tools/manual/frameviewer/editor/landmarks.py +++ b/tools/manual/frameviewer/editor/landmarks.py @@ -275,7 +275,7 @@ def _drag_start(self, event): self._drag_callback = None self._reset_selection(event) - def _drag_stop(self, event): # pylint: disable=unused-argument + def _drag_stop(self, event): # pylint:disable=unused-argument """ In select mode, call the select mode callback. In point mode: trigger a viewport thumbnail update on click + drag release diff --git a/tools/manual/frameviewer/frame.py b/tools/manual/frameviewer/frame.py index b448265c78..f42d53f79a 100644 --- a/tools/manual/frameviewer/frame.py +++ b/tools/manual/frameviewer/frame.py @@ -498,7 +498,7 @@ def _add_static_buttons(self): self._globals.tk_update.trace("w", self._disable_enable_reload_button) return buttons - def _disable_enable_copy_buttons(self, *args): # pylint: disable=unused-argument + def _disable_enable_copy_buttons(self, *args): # pylint:disable=unused-argument """ Disable or enable the static buttons """ position = self._globals.frame_index face_count_per_index = self._det_faces.face_count_per_index @@ -511,7 +511,7 @@ def _disable_enable_copy_buttons(self, *args): # pylint: disable=unused-argumen for direction in ("prev", "next"): self._static_buttons["copy_{}".format(direction)].state(states[direction]) - def _disable_enable_reload_button(self, *args): # pylint: disable=unused-argument + def _disable_enable_reload_button(self, *args): # pylint:disable=unused-argument """ Disable or enable the static buttons """ position = self._globals.frame_index state = ["!disabled"] if (position != -1 and diff --git a/tools/preview/control_panels.py b/tools/preview/control_panels.py index 2318182f17..3dc55ba2e2 100644 --- a/tools/preview/control_panels.py +++ b/tools/preview/control_panels.py @@ -249,7 +249,7 @@ def start(self) -> None: self._progress_bar.start(25) -class ActionFrame(ttk.Frame): # pylint: disable=too-many-ancestors +class ActionFrame(ttk.Frame): # pylint:disable=too-many-ancestors """ Frame that holds the left hand side options panel containing the command line options. Parameters @@ -589,7 +589,7 @@ def _add_patch_callback(self, patch_callback: Callable[[], None]) -> None: tk_var.trace("w", patch_callback) -class ConfigFrame(ttk.Frame): # pylint: disable=too-many-ancestors +class ConfigFrame(ttk.Frame): # pylint:disable=too-many-ancestors """ Holds the configuration options for a convert plugin inside the :class:`OptionsBook`. Parameters diff --git a/tools/sort/sort_methods.py b/tools/sort/sort_methods.py index 507db4ae1f..4a1501022d 100644 --- a/tools/sort/sort_methods.py +++ b/tools/sort/sort_methods.py @@ -506,8 +506,8 @@ def _get_file_iterator(self, input_dir: str) -> InfoLoader: retval = InfoLoader(input_dir, self._sorter.loader_type) else: retval = InfoLoader(input_dir, "all") - self._sorter._iterator = retval # pylint: disable=protected-access - self._grouper._iterator = retval # pylint: disable=protected-access + self._sorter._iterator = retval # pylint:disable=protected-access + self._grouper._iterator = retval # pylint:disable=protected-access return retval def score_image(self,