Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions debug_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
4 changes: 2 additions & 2 deletions examples/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
2 changes: 1 addition & 1 deletion manual-tests/test-api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def f():
fail # noqa: B018, F821
fail # ruff:ignore[useless-expression, undefined-name]


from pudb import runcall
Expand Down
2 changes: 1 addition & 1 deletion manual-tests/test-postmortem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def f():
fail # noqa: B018, F821
fail # ruff:ignore[useless-expression, undefined-name]


try:
Expand Down
8 changes: 4 additions & 4 deletions pudb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -120,7 +120,7 @@ def _have_debugger():
return False


import signal # noqa
import signal # ruff:ignore[unsorted-imports]
DEFAULT_SIGNAL = signal.SIGINT
del signal

Expand Down
4 changes: 2 additions & 2 deletions pudb/b.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions pudb/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pudb/forked.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion pudb/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pudb/lowlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pudb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions pudb/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pudb/source_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pudb/test/test_source_code_providers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pytest # noqa: F401
import pytest # ruff:ignore[unused-import]

from pudb.debugger import (
DirectSourceCodeProvider,
Expand Down
2 changes: 1 addition & 1 deletion pudb/test/test_var_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pudb/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand Down
14 changes: 7 additions & 7 deletions pudb/var_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down
31 changes: 15 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]

Expand Down Expand Up @@ -173,4 +173,3 @@ reportUnknownMemberType = "hint"
reportUnknownVariableType = "hint"
reportMissingImports = "hint"
reportMissingTypeStubs = "hint"