Skip to content

Commit

Permalink
Re-enable debug-statements pre-commit check
Browse files Browse the repository at this point in the history
  • Loading branch information
bergercookie committed Dec 31, 2023
1 parent 2c1da84 commit 999113e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ repos:
- id: check-toml
- id: check-yaml
exclude: ^tests/test_data/sample_items.yaml
# - id: debug-statements
- id: debug-statements
exclude: syncall/pdb_cli_utils.py
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
Expand Down
18 changes: 1 addition & 17 deletions syncall/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from syncall.app_utils import name_to_resolution_strategy_type
from syncall.constants import COMBINATION_FLAGS
from syncall.pdb_cli_utils import run_pdb_on_error as _run_pdb_on_error


def _set_own_excepthook(ctx, param, value):
Expand All @@ -20,23 +21,6 @@ def _set_own_excepthook(ctx, param, value):
return value


def _run_pdb_on_error(type, value, tb):
if hasattr(sys, "ps1") or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like device, so we call the
# default hook
print(f"Cannot enable the --pdb-on-error flag")
sys.__excepthook__(type, value, tb)
else:
import pdb
import traceback

traceback.print_exception(type, value, tb)
if type is KeyboardInterrupt:
return

pdb.pm()


def opt_pdb_on_error():
return click.option(
"--pdb-on-error",
Expand Down
18 changes: 18 additions & 0 deletions syncall/pdb_cli_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys


def run_pdb_on_error(type, value, tb):
if hasattr(sys, "ps1") or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like device, so we call the
# default hook
print(f"Cannot enable the --pdb-on-error flag")
sys.__excepthook__(type, value, tb)
else:
import pdb
import traceback

traceback.print_exception(type, value, tb)
if type is KeyboardInterrupt:
return

pdb.pm()

0 comments on commit 999113e

Please sign in to comment.