Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs and examples for the '--pdbcls' option #3141

Closed
nicoddemus opened this issue Jan 22, 2018 · 12 comments
Closed

Add docs and examples for the '--pdbcls' option #3141

nicoddemus opened this issue Jan 22, 2018 · 12 comments
Labels
good first issue easy issue that is friendly to new contributor type: docs documentation improvement, missing or needing clarification

Comments

@nicoddemus
Copy link
Member

From #647 (comment).

@nicoddemus nicoddemus added type: docs documentation improvement, missing or needing clarification good first issue easy issue that is friendly to new contributor labels Jan 22, 2018
@recursivelycurious
Copy link

@nicoddemus happy to tackle this if no one else is working on it per your comment on #2324 -- note I'm still open to implementing that if we think its worth doing.

@nicoddemus
Copy link
Member Author

@recursivelycurious please go ahead, thanks!

@recursivelycurious
Copy link

@nicoddemus will do :) feel free to assign it to me if that is part of the workflow.

@nicoddemus
Copy link
Member Author

Thanks, we usually do not assign, you can go ahead and open the PR when you can. 👍

@blueyed
Copy link
Contributor

blueyed commented Apr 9, 2019

JFI: by now attribute access also works, e.g. --pdbcls ipdb:__main__.debugger_cls.

@nnrepos
Copy link
Contributor

nnrepos commented Nov 2, 2019

@nicoddemus could you reference where in the code --pdbcls is implemented, or an example where it can be used? Thanks

@nicoddemus
Copy link
Member Author

@nnrepos sure, here's the option is defined:

group._addoption(
"--pdbcls",
dest="usepdb_cls",
metavar="modulename:classname",
type=_validate_usepdb_cls,
help="start a custom interactive Python debugger on errors. "
"For example: --pdbcls=IPython.terminal.debugger:TerminalPdb",
)

And here the option (the attribute usepdb_cls) is used:

def _import_pdb_cls(cls, capman):
if not cls._config:
# Happens when using pytest.set_trace outside of a test.
return pdb.Pdb
usepdb_cls = cls._config.getvalue("usepdb_cls")
if cls._wrapped_pdb_cls and cls._wrapped_pdb_cls[0] == usepdb_cls:
return cls._wrapped_pdb_cls[1]
if usepdb_cls:
modname, classname = usepdb_cls
try:
__import__(modname)
mod = sys.modules[modname]
# Handle --pdbcls=pdb:pdb.Pdb (useful e.g. with pdbpp).
parts = classname.split(".")
pdb_cls = getattr(mod, parts[0])
for part in parts[1:]:
pdb_cls = getattr(pdb_cls, part)
except Exception as exc:
value = ":".join((modname, classname))
raise UsageError(
"--pdbcls: could not import {!r}: {}".format(value, exc)
)
else:
pdb_cls = pdb.Pdb
wrapped_cls = cls._get_pdb_wrapper_class(pdb_cls, capman)
cls._wrapped_pdb_cls = (usepdb_cls, wrapped_cls)
return wrapped_cls

Let us know if you need further pointers. 👍

@Leundai
Copy link

Leundai commented Jun 5, 2020

Hi has this issue been finished yet at all?

@nicoddemus
Copy link
Member Author

Hi @Leundai, not yet, feel free to pick it up if you are interested. 👍

@yasharth291
Copy link

yasharth291 commented Aug 19, 2020

I will pick it up
@nicoddemus

@pralkarz
Copy link

I did some research and it looks like the docs have been added in #7747 and #8536.
Are we okay to close this issue now or should the docs elaborate more on the feature?

@nicoddemus
Copy link
Member Author

Thanks @ziebam!

If anything else is still missing, we can open a new issue to track that specifically. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue easy issue that is friendly to new contributor type: docs documentation improvement, missing or needing clarification
Projects
None yet
Development

No branches or pull requests

7 participants