gotcha / ipdb

Integration of IPython pdb
BSD 3-Clause "New" or "Revised" License
1.85k stars 146 forks source link

Add condition variable to set_trace #197

Closed alexandrebarbaruiva closed 4 years ago

alexandrebarbaruiva commented 4 years ago

Add condition variable to set_trace to show console only when cond=True.

This way, instead of doing

for abc in range(1, 100):
    if abc == 13:
        import ipdb; ipdb.set_trace()

You do this

for abc in range(1, 100):
    import ipdb; ipdb.set_trace(cond=(abc==13))
codecov-commenter commented 4 years ago

Codecov Report

Merging #197 into master will decrease coverage by 0.38%. The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #197      +/-   ##
==========================================
- Coverage   67.15%   66.76%   -0.39%     
==========================================
  Files           6        6              
  Lines         344      346       +2     
==========================================
  Hits          231      231              
- Misses        113      115       +2     
Impacted Files Coverage Δ
ipdb/__main__.py 46.28% <33.33%> (-0.54%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ef1bceb...8fb1879. Read the comment docs.

gotcha commented 4 years ago

Great ideas. Both the condition and the documentation improvement.

gotcha commented 4 years ago

Before merging, I'd like to see a changelog entry... and some doc for the new arg to set_trace

alexandrebarbaruiva commented 4 years ago

Changed code based on review and added documentation and a changelog entry!

gotcha commented 4 years ago

Released in https://pypi.org/project/ipdb/0.13.3/ Thanks !