Skip to content

Commit 53db861

Browse files
committed
Move code.
1 parent 2a33ab7 commit 53db861

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/_pytask/debugging.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ def pytask_extend_command_line_interface(cli: click.Group) -> None:
6060
cli.commands["build"].params.extend(additional_parameters)
6161

6262

63-
def _parse_pdbcls(value: str) -> tuple[str, str]:
63+
def _parse_pdbcls(value: str | None) -> tuple[str, str] | None:
6464
"""Parse and validate pdbcls string format."""
65+
if value is None:
66+
return None
67+
if not isinstance(value, str):
68+
msg = "'pdbcls' must be a string in format 'module:classname'"
69+
raise TypeError(msg)
6570
split = value.split(":")
6671
if len(split) != 2: # noqa: PLR2004
6772
msg = (
@@ -78,24 +83,16 @@ def _pdbcls_callback(
7883
value: str | None,
7984
) -> tuple[str, str] | None:
8085
"""Validate the debugger class string passed to pdbcls."""
81-
if value is None:
82-
return None
8386
try:
8487
return _parse_pdbcls(value)
85-
except ValueError as exc:
86-
raise click.BadParameter(str(exc)) from exc
88+
except Exception as e:
89+
raise click.BadParameter(str(e)) from e
8790

8891

8992
@hookimpl
9093
def pytask_parse_config(config: dict[str, Any]) -> None:
91-
"""Parse the debugger configuration.
92-
93-
Convert pdbcls from string format to tuple if it comes from config file.
94-
When pdbcls comes from CLI, it's already converted by _pdbcls_callback.
95-
"""
96-
pdbcls = config.get("pdbcls")
97-
if pdbcls and isinstance(pdbcls, str):
98-
config["pdbcls"] = _parse_pdbcls(pdbcls)
94+
"""Parse the debugger configuration."""
95+
config["pdbcls"] = _parse_pdbcls(config.get("pdbcls"))
9996

10097

10198
@hookimpl(trylast=True)

0 commit comments

Comments
 (0)