diff --git a/debug_me.py b/debug_me.py index f1171451..1f7e2d86 100644 --- a/debug_me.py +++ b/debug_me.py @@ -24,16 +24,16 @@ def simple_func(x): x += 1 s = range(20) - z = None # noqa: F841 - w = () # noqa: F841 + z = None # ruff:ignore[unused-variable] + w = () # ruff:ignore[unused-variable] - y = {i: i**2 for i in s} # noqa: F841 + y = {i: i**2 for i in s} # ruff:ignore[unused-variable] - k = set(range(5, 99)) # noqa: F841 - c = Color(137, 214, 56, 88) # noqa: F841 + k = set(range(5, 99)) # ruff:ignore[unused-variable] + c = Color(137, 214, 56, 88) # ruff:ignore[unused-variable] try: - x.invalid # noqa: B018 + x.invalid # ruff:ignore[useless-expression] except AttributeError: pass diff --git a/doc/conf.py b/doc/conf.py index 7e12606a..82dfeff3 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -46,4 +46,4 @@ def setup(app) -> None: - app.connect("missing-reference", process_autodoc_missing_reference) # noqa: F821 + app.connect("missing-reference", process_autodoc_missing_reference) # ruff:ignore[undefined-name] diff --git a/examples/theme.py b/examples/theme.py index 6c12e079..59957678 100644 --- a/examples/theme.py +++ b/examples/theme.py @@ -21,7 +21,7 @@ # Note, be sure to test your theme in both curses and raw mode (see the bottom # of the preferences window). Curses mode will be used with screen or tmux. -palette.update({ # noqa: F821 - "source": (add_setting("black", "underline"), "dark green"), # noqa: F821 +palette.update({ # ruff:ignore[undefined-name] + "source": (add_setting("black", "underline"), "dark green"), # ruff:ignore[undefined-name] "comment": ("h250", "default") }) diff --git a/manual-tests/test-api.py b/manual-tests/test-api.py index c157c290..29fc2ee9 100644 --- a/manual-tests/test-api.py +++ b/manual-tests/test-api.py @@ -1,5 +1,5 @@ def f(): - fail # noqa: B018, F821 + fail # ruff:ignore[useless-expression, undefined-name] from pudb import runcall diff --git a/manual-tests/test-postmortem.py b/manual-tests/test-postmortem.py index 363ee2c4..eca06f41 100644 --- a/manual-tests/test-postmortem.py +++ b/manual-tests/test-postmortem.py @@ -1,5 +1,5 @@ def f(): - fail # noqa: B018, F821 + fail # ruff:ignore[useless-expression, undefined-name] try: diff --git a/pudb/__init__.py b/pudb/__init__.py index e52d3485..bef1884a 100644 --- a/pudb/__init__.py +++ b/pudb/__init__.py @@ -55,7 +55,7 @@ class PudbShortcuts: @property - def db(self): # noqa: RUF066 + def db(self): # ruff:ignore[property-without-return] dbg = _get_debugger() import threading @@ -64,7 +64,7 @@ def db(self): # noqa: RUF066 dbg.set_trace(sys._getframe().f_back) @property - def go(self): # noqa: RUF066 + def go(self): # ruff:ignore[property-without-return] dbg = _get_debugger() import threading @@ -87,7 +87,7 @@ def _tty_override(): def _open_tty(tty_path: str): import io import os - tty_file = io.TextIOWrapper(open(tty_path, "r+b", buffering=0)) # noqa: SIM115 + tty_file = io.TextIOWrapper(open(tty_path, "r+b", buffering=0)) # ruff:ignore[open-file-with-context-handler] term_size = os.get_terminal_size(tty_file.fileno()) return tty_file, term_size @@ -120,7 +120,7 @@ def _have_debugger(): return False -import signal # noqa +import signal # ruff:ignore[unsorted-imports] DEFAULT_SIGNAL = signal.SIGINT del signal diff --git a/pudb/b.py b/pudb/b.py index f6340a02..cff88c9c 100644 --- a/pudb/b.py +++ b/pudb/b.py @@ -5,10 +5,10 @@ from pudb import _get_debugger, set_interrupt_handler -def __myimport__(name, *args, **kwargs): # noqa: N807 +def __myimport__(name, *args, **kwargs): # ruff:ignore[dunder-function-name] if name == "pudb.b": set_trace() - return __origimport__(name, *args, **kwargs) # noqa: F821 # pylint: disable=undefined-variable + return __origimport__(name, *args, **kwargs) # ruff:ignore[undefined-name] # pylint: disable=undefined-variable # Will only be run on first import diff --git a/pudb/debugger.py b/pudb/debugger.py index 5c23a3e2..6342436b 100644 --- a/pudb/debugger.py +++ b/pudb/debugger.py @@ -1942,7 +1942,9 @@ def cmdline_tab_complete(w, size, key): return try: - from packaging.version import parse as LooseVersion # noqa: N812 + from packaging.version import ( + parse as LooseVersion, # ruff:ignore[lowercase-imported-as-non-lowercase] + ) except ImportError: from distutils.version import LooseVersion @@ -2286,7 +2288,7 @@ def fallback(error_message): from os.path import expanduser, expandvars cshell_fname = expanduser(expandvars(CONFIG["shell"])) with open(cshell_fname) as inf: - exec(compile(inf.read(), cshell_fname, "exec"), # noqa: S102 + exec(compile(inf.read(), cshell_fname, "exec"), # ruff:ignore[exec-builtin] shell.custom_shell_dict, shell.custom_shell_dict) except FileNotFoundError: @@ -2323,7 +2325,7 @@ class RHColumnFocuser: def __init__(self, idx): self.idx = idx - def __call__(subself, w, size, key): # noqa # pylint: disable=no-self-argument + def __call__(subself, w, size, key): # ruff:ignore[invalid-first-argument-name-for-method] # pylint: disable=no-self-argument focus_widget_in_container(self.columns, self.rhs_col_sigwrap) self.rhs_col.focus_position = subself.idx @@ -2507,7 +2509,7 @@ def dialog(self, if extra_bindings is None: extra_bindings = [] - Attr = urwid.AttrMap # noqa + Attr = urwid.AttrMap # ruff:ignore[non-lowercase-variable-in-function] if bind_enter_esc: content = SignalWrap(content) @@ -2717,14 +2719,14 @@ def event_loop(self, toplevel: urwid.Widget | None = None) -> object: prev_quit_loop = self.quit_event_loop try: - import pygments # noqa + import pygments # ruff:ignore[unused-import] except ImportError: if not hasattr(self, "pygments_message_shown"): self.pygments_message_shown = True self.message("Package 'pygments' not found. " "Syntax highlighting disabled.") - WELCOME_LEVEL = "e056" # noqa + WELCOME_LEVEL = "e056" # ruff:ignore[non-lowercase-variable-in-function] if CONFIG["seen_welcome"] < WELCOME_LEVEL: CONFIG["seen_welcome"] = WELCOME_LEVEL from pudb import VERSION diff --git a/pudb/forked.py b/pudb/forked.py index 00a7667b..70b7f5ca 100644 --- a/pudb/forked.py +++ b/pudb/forked.py @@ -30,7 +30,7 @@ def set_trace(paused=True, frame=None, term_size=None): term_size = (80, 24) Debugger( - stdin=open("/dev/stdin"), # noqa: SIM115 - stdout=open("/dev/stdout", "w"), # noqa: SIM115 + stdin=open("/dev/stdin"), # ruff:ignore[open-file-with-context-handler] + stdout=open("/dev/stdout", "w"), # ruff:ignore[open-file-with-context-handler] term_size=term_size, ).set_trace(frame, paused=paused) diff --git a/pudb/ipython.py b/pudb/ipython.py index c553280f..156cdcef 100644 --- a/pudb/ipython.py +++ b/pudb/ipython.py @@ -46,7 +46,7 @@ def debugger(self, force=False): return if not hasattr(sys, "last_traceback"): - error("No traceback has been produced, nothing to debug.") # noqa: LOG015 + error("No traceback has been produced, nothing to debug.") # ruff:ignore[root-logger-call] return from pudb import pm diff --git a/pudb/lowlevel.py b/pudb/lowlevel.py index 4ac2b2a7..8337f426 100644 --- a/pudb/lowlevel.py +++ b/pudb/lowlevel.py @@ -53,7 +53,7 @@ def setlogfile(destfile: str): logfile[0] = destfile with open(destfile, "a") as openfile: openfile.write( - f"\n*** Pudb session error log started at {datetime.now()} ***\n") # noqa: DTZ005 + f"\n*** Pudb session error log started at {datetime.now()} ***\n") # ruff:ignore[call-datetime-now-without-tzinfo] # once we've dropped Py3.8 support, use this instead: diff --git a/pudb/settings.py b/pudb/settings.py index b6cf2b67..f4a604fd 100644 --- a/pudb/settings.py +++ b/pudb/settings.py @@ -102,8 +102,8 @@ def get_save_config_path(): CONF_SECTION = "pudb" CONF_FILE_NAME = "pudb.cfg" -SAVED_BREAKPOINTS_FILE_NAME = "saved-breakpoints-%d.%d" % sys.version_info[:2] # noqa: UP031 -BREAKPOINTS_FILE_NAME = "breakpoints-%d.%d" % sys.version_info[:2] # noqa: UP031 +SAVED_BREAKPOINTS_FILE_NAME = "saved-breakpoints-%d.%d" % sys.version_info[:2] # ruff:ignore[printf-string-formatting] +BREAKPOINTS_FILE_NAME = "breakpoints-%d.%d" % sys.version_info[:2] # ruff:ignore[printf-string-formatting] _config_: list[ConfDict | None] = [None] diff --git a/pudb/shell.py b/pudb/shell.py index 62b87703..42438128 100644 --- a/pudb/shell.py +++ b/pudb/shell.py @@ -8,7 +8,7 @@ # Access a property to verify module exists in case # there's a demand loader wrapping module imports # See https://github.com/inducer/pudb/issues/177 - bpython.__version__ # noqa: B018 + bpython.__version__ # ruff:ignore[useless-expression] except ImportError: HAVE_BPYTHON = False else: @@ -141,7 +141,7 @@ def have_ipython(): # Access a property to verify module exists in case # there's a demand loader wrapping module imports # See https://github.com/inducer/pudb/issues/177 - IPython.core # noqa: B018 + IPython.core # ruff:ignore[useless-expression] except (ImportError, ValueError): # Old IPythons versions (0.12?) may fail to import with # ValueError: fallback required, but not specified diff --git a/pudb/source_view.py b/pudb/source_view.py index a26e54c6..67c3d062 100644 --- a/pudb/source_view.py +++ b/pudb/source_view.py @@ -226,7 +226,7 @@ def parse_token(self, token, s): try: - import pygments # noqa + import pygments # ruff:ignore[unused-import] except ImportError: def format_source( debugger_ui: DebuggerUI, diff --git a/pudb/test/test_source_code_providers.py b/pudb/test/test_source_code_providers.py index f154e495..71eb2a2d 100644 --- a/pudb/test/test_source_code_providers.py +++ b/pudb/test/test_source_code_providers.py @@ -1,4 +1,4 @@ -import pytest # noqa: F401 +import pytest # ruff:ignore[unused-import] from pudb.debugger import ( DirectSourceCodeProvider, diff --git a/pudb/test/test_var_view.py b/pudb/test/test_var_view.py index a9bf26ab..2bbb8163 100644 --- a/pudb/test/test_var_view.py +++ b/pudb/test/test_var_view.py @@ -140,7 +140,7 @@ def __init__(self, iterable): @classmethod def name(cls): return "ContainerlikeClass:{}".format( - ":".join(selected_methods)) # noqa: B023 + ":".join(selected_methods)) # ruff:ignore[function-uses-loop-variable] for method in selected_methods: func = method_factory(method) diff --git a/pudb/theme.py b/pudb/theme.py index 18b98e85..b9c0ad34 100644 --- a/pudb/theme.py +++ b/pudb/theme.py @@ -296,7 +296,7 @@ def get_palette(may_use_fancy_formats: bool, theme: str = "classic") -> list: from os.path import expanduser, expandvars fname = expanduser(expandvars(theme)) with open(fname) as inf: - exec(compile(inf.read(), fname, "exec"), symbols) # noqa: S102 + exec(compile(inf.read(), fname, "exec"), symbols) # ruff:ignore[exec-builtin] except FileNotFoundError: ui_log.error(f"Unable to locate custom theme file {theme!r}" ) diff --git a/pudb/var_view.py b/pudb/var_view.py index 425f736c..e7339f7a 100644 --- a/pudb/var_view.py +++ b/pudb/var_view.py @@ -61,7 +61,7 @@ # {{{ abstract base classes for containers -class PudbCollection(ABC): # noqa: B024 +class PudbCollection(ABC): # ruff:ignore[abstract-base-class-without-abstract-method] @classmethod def __subclasshook__(cls, c): if cls is PudbCollection: @@ -70,7 +70,7 @@ def __subclasshook__(cls, c): any("__contains__" in b.__dict__ for b in c.__mro__), any("__iter__" in b.__dict__ for b in c.__mro__), ]) - except Exception: # noqa: S110 + except Exception: # ruff:ignore[try-except-pass] pass return NotImplemented @@ -93,7 +93,7 @@ def length(cls, collection): return len(collection) -class PudbSequence(ABC): # noqa: B024 +class PudbSequence(ABC): # ruff:ignore[abstract-base-class-without-abstract-method] @classmethod def __subclasshook__(cls, c): if cls is PudbSequence: @@ -102,7 +102,7 @@ def __subclasshook__(cls, c): any("__getitem__" in b.__dict__ for b in c.__mro__), any("__iter__" in b.__dict__ for b in c.__mro__), ]) - except Exception: # noqa: S110 + except Exception: # ruff:ignore[try-except-pass] pass return NotImplemented @@ -125,7 +125,7 @@ def length(cls, sequence): return len(sequence) -class PudbMapping(ABC): # noqa: B024 +class PudbMapping(ABC): # ruff:ignore[abstract-base-class-without-abstract-method] @classmethod def __subclasshook__(cls, c): if cls is PudbMapping: @@ -135,7 +135,7 @@ def __subclasshook__(cls, c): any("__iter__" in b.__dict__ for b in c.__mro__), any("keys" in b.__dict__ for b in c.__mro__), ]) - except Exception: # noqa: S110 + except Exception: # ruff:ignore[try-except-pass] pass return NotImplemented @@ -537,7 +537,7 @@ def get_stringifier(iinfo: InspectInfo) -> Callable[[object], str]: from os.path import expanduser, expandvars custom_stringifier_fname = expanduser(expandvars(iinfo.display_type)) with open(custom_stringifier_fname) as inf: - exec(compile(inf.read(), custom_stringifier_fname, "exec"), # noqa: S102 + exec(compile(inf.read(), custom_stringifier_fname, "exec"), # ruff:ignore[exec-builtin] custom_stringifier_dict, custom_stringifier_dict) except FileNotFoundError: diff --git a/pyproject.toml b/pyproject.toml index 262e50fe..c37588a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,18 +93,18 @@ extend-select = [ ] extend-ignore = [ "C90", # McCabe complexity - "E221", # multiple spaces before operator - "E226", # missing whitespace around arithmetic operator - "E241", # multiple spaces after comma - "E242", # tab after comma - "E402", # module level import not at the top of file - "N818", # error suffix in exception names + "multiple-spaces-before-operator", + "missing-whitespace-around-arithmetic-operator", + "multiple-spaces-after-comma", + "tab-after-comma", + "module-import-not-at-top-of-file", + "error-suffix-on-exception-name", # Agree in principle, but this is a bigger change... - "RUF067", # no code in __init__ + "non-empty-init-module", - "BLE001", - "TRY300", + "blind-except", + "try-consider-else", ] [tool.ruff.lint.flake8-quotes] docstring-quotes = "double" @@ -120,12 +120,12 @@ lines-after-imports = 2 required-imports = ["from __future__ import annotations"] [tool.ruff.lint.per-file-ignores] -"pudb/themes/*.py" = ["I002"] -"debug_me.py" = ["I002", "T100"] -"doc/conf.py" = ["I002", "S102"] -"examples/*.py" = ["I002"] -"pudb/test/*.py" = ["I002", "S102"] -"manual-tests/*.py" = ["I002"] +"pudb/themes/*.py" = ["missing-required-import"] +"debug_me.py" = ["missing-required-import", "debugger"] +"doc/conf.py" = ["missing-required-import", "exec-builtin"] +"examples/*.py" = ["missing-required-import"] +"pudb/test/*.py" = ["missing-required-import", "exec-builtin"] +"manual-tests/*.py" = ["missing-required-import"] [tool.pytest.ini_options] @@ -173,4 +173,3 @@ reportUnknownMemberType = "hint" reportUnknownVariableType = "hint" reportMissingImports = "hint" reportMissingTypeStubs = "hint" -