diff --git a/.flake8 b/.flake8 index aa0e2f2c1..e7c10e25e 100644 --- a/.flake8 +++ b/.flake8 @@ -9,8 +9,10 @@ ignore = E402, C901, E722, - W503, # line break before binary operator - E231, # missing whitespace after ',' + W503, + # line break before binary operator + E231, + # missing whitespace after ',' max-line-length = 100 exclude = env,.direnv,docs max-complexity = 25 diff --git a/.pylintrc b/.pylintrc index 8745067d2..dd3b0a31d 100644 --- a/.pylintrc +++ b/.pylintrc @@ -63,7 +63,6 @@ confidence= disable= arguments-differ, attribute-defined-outside-init, - bad-continuation, broad-except, consider-using-ternary, deprecated-method, @@ -73,12 +72,10 @@ disable= import-error, # needed for travis build inconsistent-return-statements, invalid-name, - locally-enabled, missing-docstring, no-member, no-method-argument, no-name-in-module, - no-self-use, no-value-for-parameter, pointless-string-statement, protected-access, @@ -86,11 +83,13 @@ disable= too-few-public-methods, too-many-arguments, too-many-boolean-expressions, + too-many-branches, too-many-instance-attributes, too-many-lines, too-many-locals, too-many-nested-blocks, too-many-public-methods, + too-many-positional-arguments, too-many-statements, undefined-variable, ungrouped-imports, @@ -307,13 +306,6 @@ max-line-length=100 # Maximum number of lines in a module. max-module-lines=1000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no diff --git a/Pipfile b/Pipfile index 7426f045e..46527e5ac 100644 --- a/Pipfile +++ b/Pipfile @@ -8,10 +8,9 @@ python_version = "3" [dev-packages] "autopep8" = "*" -"flake8" = ">=3.8.0,<4.0.0" +"flake8" = "==7.1.1" "pep8" = "*" -pylint = "*" -typed-ast = "*" +pylint = "==3.3.2" astroid = "*" fiximports = ">=0.1.18" mock = ">=2.0.0" @@ -31,8 +30,8 @@ scandir = {markers = "python_version > '3.5'"} pyfakefs = "*" pytest-cov = "*" pew = "*" -black = "==21.8b0" -flakehell = "*" +black = "==24.10.0" +typing-extensions = "*" toml = "*" pre-commit = "==2.17.0" diff --git a/Pipfile.lock b/Pipfile.lock index e304c3176..b0017392d 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "fdecd7a6a22203e2660a1a3cd279302611cec90e5ccd0fe0e52fd975c13de430" + "sha256": "1530c3cb45d3abb60f48c884b591f6e1ba2021b93a0a5409cf3876d4efdcaf67" }, "pipfile-spec": 6, "requires": { @@ -107,11 +107,12 @@ }, "autopep8": { "hashes": [ - "sha256:276ced7e9e3cb22e5d7c14748384a5cf5d9002257c0ed50c0e075b68011bb6d0", - "sha256:aa213493c30dcdac99537249ee65b24af0b2c29f2e83cd8b3f68760441ed0db9" + "sha256:8d6c87eba648fdcfc83e29b788910b8643171c395d9c4bcf115ece035b9c9dda", + "sha256:a203fe0fcad7939987422140ab17a930f684763bf7335bdb6709991dd7ef6c2d" ], "index": "pypi", - "version": "==1.5.7" + "markers": "python_version >= '3.8'", + "version": "==2.3.1" }, "babel": { "hashes": [ @@ -223,14 +224,6 @@ "markers": "python_version >= '3.6'", "version": "==8.0.4" }, - "colorama": { - "hashes": [ - "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b", - "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==0.4.4" - }, "colorlog": { "hashes": [ "sha256:344f73204009e4c83c5b6beb00b3c45dc70fcdae3c80db919e0a4171d006fde8", @@ -379,18 +372,6 @@ "markers": "python_version >= '3.6'", "version": "==0.20.35" }, - "e1839a8": { - "editable": true, - "path": "." - }, - "entrypoints": { - "hashes": [ - "sha256:b706eddaa9218a19ebcd67b56818f05bb27589b1ca9e8d797b74affad4ccacd4", - "sha256:f174b5ff827504fd3cd97cc3f8649f3693f51538c7e4bdf3ef002c8429d42f9f" - ], - "markers": "python_version >= '3.6'", - "version": "==0.4" - }, "filelock": { "hashes": [ "sha256:0f12f552b42b5bf60dba233710bf71337d35494fc8bdd4fd6d9f6d082ad45e06", @@ -409,23 +390,12 @@ }, "flake8": { "hashes": [ - "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b", - "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907" + "sha256:049d058491e228e03e67b390f311bbf88fce2dbaa8fa673e7aea87b7198b8d38", + "sha256:597477df7860daa5aa0fdd84bf5208a043ab96b8e96ab708770ae0364dd03213" ], "index": "pypi", - "version": "==3.9.2" - }, - "flakehell": { - "hashes": [ - "sha256:208836d8d24194d50cfa4c1fc99f681f3c537cc232edcd06455abc2971460893", - "sha256:48a3a9b46136240e52b3b32a78a0826c45f6dcf7d980c30f758c1db5b1439c0b" - ], - "index": "pypi", - "version": "==0.9.0" - }, - "guake": { - "editable": true, - "path": "." + "markers": "python_full_version >= '3.8.1'", + "version": "==7.1.1" }, "identify": { "hashes": [ @@ -626,10 +596,11 @@ }, "mccabe": { "hashes": [ - "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", - "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325", + "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e" ], - "version": "==0.6.1" + "markers": "python_version >= '3.6'", + "version": "==0.7.0" }, "mock": { "hashes": [ @@ -774,11 +745,11 @@ }, "pycodestyle": { "hashes": [ - "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068", - "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef" + "sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3", + "sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==2.7.0" + "markers": "python_version >= '3.8'", + "version": "==2.12.1" }, "pycparser": { "hashes": [ @@ -797,11 +768,12 @@ }, "pyflakes": { "hashes": [ - "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3", - "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db" + "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f", + "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a" ], "index": "pypi", - "version": "==2.3.1" + "markers": "python_version >= '3.8'", + "version": "==3.2.0" }, "pygments": { "hashes": [ diff --git a/guake/about.py b/guake/about.py index d3e6f6071..594e4d803 100644 --- a/guake/about.py +++ b/guake/about.py @@ -31,7 +31,6 @@ class AboutDialog(SimpleGladeApp): - """The About Guake dialog class""" def __init__(self): diff --git a/guake/boxes.py b/guake/boxes.py index 5233b0cf9..665ded971 100644 --- a/guake/boxes.py +++ b/guake/boxes.py @@ -167,8 +167,7 @@ def get_terminals(self): def iter_terminals(self): if self.get_child() is not None: - for t in self.get_child().iter_terminals(): - yield t + yield from self.get_child().iter_terminals() def replace_child(self, old, new): self.remove(old) @@ -221,17 +220,14 @@ def save_box_layout(self, box, panes: list): def restore_box_layout(self, box, panes: list): """Restore box layout by `panes`""" - if not panes or not isinstance(panes, list): - return - if not box or not isinstance(box, TerminalBox): - # Should only called on TerminalBox + if not panes or not isinstance(panes, list) or not box or not isinstance(box, TerminalBox): return cur = panes.pop(0) if cur["type"].startswith("dual"): while True: if self.guake: - # If Guake are not visible, we should pending the restore, then do the + # If Guake is not visible, we should pending the restore, then do the # restore when Guake is visible again. # # Otherwise we will stuck in the infinite loop, since new DualTerminalBox @@ -384,7 +380,6 @@ def do_search(self, widget): class TerminalBox(Gtk.Box, TerminalHolder): - """A box to group the terminal and a scrollbar.""" def __init__(self): @@ -588,10 +583,8 @@ def get_terminals(self): return self.get_child1().get_terminals() + self.get_child2().get_terminals() def iter_terminals(self): - for t in self.get_child1().iter_terminals(): - yield t - for t in self.get_child2().iter_terminals(): - yield t + yield from self.get_child1().iter_terminals() + yield from self.get_child2().iter_terminals() def replace_child(self, old, new): if self.get_child1() is old: diff --git a/guake/customcommands.py b/guake/customcommands.py index b68b12535..fc0a8debb 100644 --- a/guake/customcommands.py +++ b/guake/customcommands.py @@ -11,7 +11,6 @@ class CustomCommands: - """ Example for a custom commands file [ diff --git a/guake/dialogs.py b/guake/dialogs.py index 9605d9bc1..6e48d628d 100644 --- a/guake/dialogs.py +++ b/guake/dialogs.py @@ -38,7 +38,6 @@ def get_text(self): class PromptQuitDialog(Gtk.MessageDialog): - """Prompts the user whether to quit/close a tab.""" def __init__(self, parent, procs, tabs, notebooks): @@ -99,7 +98,6 @@ def close_tab(self): class PromptResetColorsDialog(Gtk.MessageDialog): - """Prompts the user whether to reset tab colors.""" def __init__(self, parent): diff --git a/guake/gsettings.py b/guake/gsettings.py index fe0e2b0f9..ea5d91b32 100644 --- a/guake/gsettings.py +++ b/guake/gsettings.py @@ -32,7 +32,6 @@ class GSettingHandler: - """Handles gconf changes, if any gconf variable is changed, a different method is called to handle this change. """ diff --git a/guake/guake_app.py b/guake/guake_app.py index 48074dbe8..20ea92f60 100644 --- a/guake/guake_app.py +++ b/guake/guake_app.py @@ -98,7 +98,6 @@ class Guake(SimpleGladeApp): - """Guake main class. Handles specialy the main window.""" def __init__(self): @@ -288,9 +287,7 @@ def window_event(*args): filename = pixmapfile("guake-notification.png") notifier.showMessage( _("Guake Terminal"), - _("Guake is now running,\n" "press {!s} to use it.").format( - xml_escape(label) - ), + _("Guake is now running,\npress {!s} to use it.").format(xml_escape(label)), filename, ) diff --git a/guake/keybindings.py b/guake/keybindings.py index 7ef302ee9..bfd76fa1e 100644 --- a/guake/keybindings.py +++ b/guake/keybindings.py @@ -36,7 +36,6 @@ class Keybindings: - """Handles changes in keyboard shortcuts.""" def __init__(self, guake): diff --git a/guake/main.py b/guake/main.py index f26c02f2b..e10c256a5 100644 --- a/guake/main.py +++ b/guake/main.py @@ -288,7 +288,7 @@ def main(): dest="bgcolor", action="store", default="", - help=_("Set the hexadecimal (#rrggbb) background color of " "the selected tab."), + help=_("Set the hexadecimal (#rrggbb) background color of the selected tab."), ) parser.add_argument( @@ -296,7 +296,7 @@ def main(): dest="fgcolor", action="store", default="", - help=_("Set the hexadecimal (#rrggbb) foreground color of the " "selected tab."), + help=_("Set the hexadecimal (#rrggbb) foreground color of the selected tab."), ) parser.add_argument( @@ -304,7 +304,7 @@ def main(): dest="bgcolor_current", action="store", default="", - help=_("Set the hexadecimal (#rrggbb) background color of " "the current terminal."), + help=_("Set the hexadecimal (#rrggbb) background color of the current terminal."), ) parser.add_argument( @@ -312,7 +312,7 @@ def main(): dest="fgcolor_current", action="store", default="", - help=_("Set the hexadecimal (#rrggbb) foreground color of " "the current terminal."), + help=_("Set the hexadecimal (#rrggbb) foreground color of the current terminal."), ) parser.add_argument( @@ -346,8 +346,7 @@ def main(): action="store", default="", help=_( - "Rename the specified tab by --tab-index. Reset to default if TITLE is " - 'a single dash "-".' + 'Rename tab specified by --tab-index. Reset to default if TITLE is a single dash "-".' ), ) @@ -358,7 +357,7 @@ def main(): metavar="TITLE", action="store", default="", - help=_("Rename the current tab. Reset to default if TITLE is a " 'single dash "-".'), + help=_('Rename the current tab. Reset to default if TITLE is a single dash "-".'), ) parser.add_argument( diff --git a/guake/notebook.py b/guake/notebook.py index dc24559f0..90cb58bf7 100644 --- a/guake/notebook.py +++ b/guake/notebook.py @@ -302,8 +302,7 @@ def has_page(self): def iter_terminals(self): for page in self.iter_pages(): if page is not None: - for t in page.iter_terminals(): - yield t + yield from page.iter_terminals() def iter_tabs(self): for page_num in range(self.get_n_pages()): @@ -613,8 +612,7 @@ def get_terminals(self): def iter_terminals(self): for k in self.notebooks: - for t in self.notebooks[k].iter_terminals(): - yield t + yield from self.notebooks[k].iter_terminals() def get_terminal_by_uuid(self, terminal_uuid): for t in self.iter_terminals(): @@ -624,8 +622,7 @@ def get_terminal_by_uuid(self, terminal_uuid): def iter_pages(self): for k in self.notebooks: - for t in self.notebooks[k].iter_pages(): - yield t + yield from self.notebooks[k].iter_pages() def iter_notebooks(self): for k in self.notebooks: diff --git a/guake/prefs.py b/guake/prefs.py index 9452c64c7..2ad41f6b5 100644 --- a/guake/prefs.py +++ b/guake/prefs.py @@ -233,7 +233,6 @@ def refresh_user_start(settings): class PrefsCallbacks: - """Holds callbacks that will be used in the PrefsDialg class.""" def __init__(self, prefDlg): @@ -544,9 +543,11 @@ def on_background_image_file_chooser_file_changed(self, fc): ) # only allow files with these extensions self.settings.general.set_string( "background-image-file", - fc.get_filename() - if fc.get_filename() and fc.get_filename().endswith(allowed_extensions) - else "", + ( + fc.get_filename() + if fc.get_filename() and fc.get_filename().endswith(allowed_extensions) + else "" + ), ) def on_background_image_file_remove_clicked(self, btn): @@ -640,7 +641,6 @@ def gtk_widget_destroy(self, btn): class PrefsDialog(SimpleGladeApp): - """The Guake Preferences dialog.""" def __init__(self, settings): diff --git a/guake/terminal.py b/guake/terminal.py index fd5684efb..2e587d7c7 100644 --- a/guake/terminal.py +++ b/guake/terminal.py @@ -94,7 +94,6 @@ class DropTargets(IntEnum): class GuakeTerminal(Vte.Terminal): - """Just a vte.Terminal with some properties already set.""" def __init__(self, guake): @@ -359,6 +358,8 @@ def button_press(self, terminal, event): int(event.x / self.get_char_width()), int(event.y / self.get_char_height()), ) + else: + matched_string = None self.found_link = None @@ -371,7 +372,7 @@ def button_press(self, terminal, event): self._on_ctrl_click_matcher((s, None)) elif self.get_has_selection(): self.quick_open() - elif matched_string and matched_string[0]: + elif matched_string is not None and matched_string[0]: self._on_ctrl_click_matcher(matched_string) elif event.button == 3 and matched_string: self.found_link = self.handleTerminalMatch(matched_string) @@ -655,9 +656,11 @@ def get_custom_colors_dict(self): return { "fg_color": self._color_to_list(self.custom_fgcolor), "bg_color": self._color_to_list(self.custom_bgcolor), - "palette": [self._color_to_list(col) for col in self.custom_palette] - if self.custom_palette - else None, + "palette": ( + [self._color_to_list(col) for col in self.custom_palette] + if self.custom_palette + else None + ), } def set_custom_colors_from_dict(self, colors_dict): diff --git a/requirements-dev.txt b/requirements-dev.txt index 1cb2e4f40..2ec9dba8b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,14 +1,98 @@ -################################################################################ -# This requirements file has been automatically generated from `Pipfile` with -# `pipenv-to-requirements` -# -# -# This has been done to maintain backward compatibility with tools and services -# that do not support `Pipfile` yet. -# -# Do NOT edit it directly, use `pipenv install [-d]` to modify `Pipfile` and -# `Pipfile.lock` and then regenerate `requirements*.txt`. -################################################################################ +-i https://pypi.python.org/simple +alabaster==1.0.0; python_version >= '3.10' +astroid==3.3.8; python_full_version >= '3.9.0' +autopep8==2.3.1; python_version >= '3.8' +babel==2.16.0; python_version >= '3.8' +black==24.10.0; python_version >= '3.9' +certifi==2024.12.14; python_version >= '3.6' +cffi==1.17.1; python_version >= '3.8' +cfgv==3.4.0; python_version >= '3.8' +charset-normalizer==3.4.1; python_version >= '3.7' +click==8.1.8; python_version >= '3.7' +colorlog==6.9.0; python_version >= '3.6' +coverage[toml]==7.6.10; python_version >= '3.9' +cryptography==44.0.0; python_version >= '3.7' and python_full_version not in '3.9.0, 3.9.1' +dill==0.3.9; python_version >= '3.8' +distlib==0.3.9 +docutils==0.21.2; python_version >= '3.9' +dulwich==0.22.7; python_version >= '3.9' +filelock==3.16.1; python_version >= '3.8' +fiximports==0.1.18 +flake8==7.1.1; python_full_version >= '3.8.1' +identify==2.6.4; python_version >= '3.9' +idna==3.10; python_version >= '3.6' +imagesize==1.4.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +iniconfig==2.0.0; python_version >= '3.7' +isort==5.13.2; python_full_version >= '3.8.0' +jaraco.classes==3.4.0; python_version >= '3.8' +jaraco.context==6.0.1; python_version >= '3.8' +jaraco.functools==4.1.0; python_version >= '3.8' +jeepney==0.8.0; python_version >= '3.7' +jinja2==3.1.5; python_version >= '3.7' +keyring==25.6.0; python_version >= '3.9' +markdown-it-py==3.0.0; python_version >= '3.8' +markupsafe==3.0.2; python_version >= '3.9' +mccabe==0.7.0; python_version >= '3.6' +mdurl==0.1.2; python_version >= '3.7' +mock==5.1.0; python_version >= '3.6' +more-itertools==10.5.0; python_version >= '3.8' +mypy-extensions==1.0.0; python_version >= '3.5' +nh3==0.2.20; python_version >= '3.8' +nodeenv==1.9.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6' +packaging==24.2; python_version >= '3.8' +pathlib2==2.3.7.post1 +pathspec==0.12.1; python_version >= '3.8' +pbr==6.1.0; python_version >= '2.6' +pep8==1.7.1 +pew==1.2.0 +pip==24.3.1; python_version >= '3.8' +pkginfo==1.12.0; python_version >= '3.8' +platformdirs==4.3.6; python_version >= '3.8' +pluggy==1.5.0; python_version >= '3.8' +pre-commit==2.17.0; python_full_version >= '3.6.1' +pycodestyle==2.12.1; python_version >= '3.8' +pycparser==2.22; python_version >= '3.8' +pyfakefs==5.7.3; python_version >= '3.7' +pyflakes==3.2.0; python_version >= '3.8' +pygments==2.18.0; python_version >= '3.8' +pylint==3.3.2; python_full_version >= '3.9.0' +pytest==8.3.4; python_version >= '3.8' +pytest-cov==6.0.0; python_version >= '3.9' +pytest-mock==3.14.0; python_version >= '3.8' +pyyaml==6.0.2; python_version >= '3.8' +readme-renderer==44.0; python_version >= '3.9' +reno[sphinx]==4.1.0; python_version >= '3.6' +requests==2.32.3; python_version >= '3.8' +requests-toolbelt==1.0.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +rfc3986==2.0.0; python_version >= '3.7' +rich==13.9.4; python_full_version >= '3.8.0' +scandir==1.10.0; python_version > '3.5' +secretstorage==3.3.3; python_version >= '3.6' +setuptools==75.6.0; python_version >= '3.9' +six==1.17.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2' +snowballstemmer==2.2.0 +sphinx==8.1.3; python_version >= '3.10' +sphinx-rtd-theme==3.0.2; python_version >= '3.8' +sphinxcontrib-applehelp==2.0.0; python_version >= '3.9' +sphinxcontrib-devhelp==2.0.0; python_version >= '3.9' +sphinxcontrib-htmlhelp==2.1.0; python_version >= '3.9' +sphinxcontrib-jquery==4.1; python_version >= '2.7' +sphinxcontrib-jsmath==1.0.1; python_version >= '3.5' +sphinxcontrib-programoutput==0.18; python_version >= '3.8' +sphinxcontrib-qthelp==2.0.0; python_version >= '3.9' +sphinxcontrib-serializinghtml==2.0.0; python_version >= '3.9' +toml==0.10.2; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2' +tomli==2.2.1; python_version >= '3.8' +tomlkit==0.13.2; python_version >= '3.8' +twine==6.0.1; python_version >= '3.8' +typing-extensions==4.12.2; python_version >= '3.8' +urllib3==2.3.0; python_version >= '3.9' +virtualenv==20.28.0; python_version >= '3.8' +virtualenv-clone==0.5.7; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +yapf==0.43.0; python_version >= '3.7' +cython==3.0.11; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +typing==3.7.4.3; python_version > '3.5' +wheel==0.45.1; python_version >= '3.8' -e . astroid @@ -25,7 +109,7 @@ pew pipenv-to-requirements pyfakefs pyflakes -pylint +pylint==3.3.2 pytest pytest-cov pytest-mock