Tuesday, September 18, 2012

Tracking down unused variables with Pyflakes and git bisect

I was working on a Python project when I noticed a variable that was defined but never used. Does this indicate that some important code was accidentally deleted? Or was there just a minor oversight during refactoring?

To answer this question, I wanted to see the Git commit which removed the last use of this variable. This sounds like a job for git bisect. And because Pyflakes can detect unused variables, the whole process is completely automatic.

I made a guess that the mystery_variable became unused sometime within the past two weeks. Then I told Git to consider a commit "good" if Pyflakes's list of complaints does not mention mystery_variable.

$ git bisect start master master@{'2 weeks ago'}
Already on 'master'
Bisecting: 150 revisions left to test after this (roughly 7 steps)
[066327622129dbe863f6e2fc4746ff9e869bd049] Synthesize gravity

$ git bisect run bash -c '! pyflakes foo.py | grep mystery_variable'
running bash -c ! pyflakes foo.py | grep mystery_variable
Bisecting: 75 revisions left to test after this (roughly 6 steps)
[d3a5665eff478cccfb86d994a8fc289446325fbf] Model object components
running bash -c ! pyflakes foo.py | grep mystery_variable
Bisecting: 37 revisions left to test after this (roughly 5 steps)
[6ddcfbf27a1a4548acf972a6b817e485743f6bd9] Time-compress simulator clock
...

running bash -c ! pyflakes foo.py | grep mystery_variable
9c2b2f006207ae9f274f9182efeb3e009d18ed04 is the first bad commit
commit 9c2b2f006207ae9f274f9182efeb3e009d18ed04
Author: Ben Bitdiddle <bitdiddle@example.com>
Date:   Fri Sep 14 01:38:31 2012 -0400

    Reticulate splines

Now I can examine this commit and see what happened.

109 comments:

  1. Another option that is often useful is to run "git log -Smystery_variable" (just in case you were not aware of it).

    ReplyDelete
  2. Nice article, thanks for the information. It's very complete information. I will bookmark for next reference
    jaring futsal | jaring golf | jaring pengaman proyek |
    jaring pengaman bangunan | jaring pengaman gedung
    http://www.jual-jaring.blogspot.com/
    http://www.agen-jaring.blogspot.com/
    http://www.pancasamudera-safetynet.blogspot.com/
    http://www.toko-jaring.blogspot.com/
    http://www.pusat-jaring.blogspot.com/
    http://jualjaringpengaman.blogspot.com/
    https://pancasamudera.wordpress.com/
    https://pasangjaringfutsal.wordpress.com/
    https://jualtambangmurah.wordpress.com/
    https://tokojaring.wordpress.com/
    https://jualjaringfutsal.wordpress.com/
    https://jaringfutsal.wordpress.com/


    ReplyDelete
  3. Our strong network of movers and packers in India assist us to reach you anywhere in India and relocate you from your existing place to the desired destination.
    Packers and Movers Faridabad
    Packers and Movers Delhi
    Packers and Movers Ghaziabad
    Packers and Movers Noida

    ReplyDelete
  4. Exoprt Packers and Movers in India are known to provide moving & packing services at the rates that actually fit in make you local shifting solutions experts for amazing only.
    Packers and Movers in Bangalore
    Packers and Movers in Hyderabad
    Packers and Movers in Chennai
    Packers and Movers in Mumbai
    Packers and Movers in Pune

    ReplyDelete
  5. How did you can avail the experts services of listed Adword India's No 1 companies?
    Thanks for information visit: http://www.adword.co.in/

    ReplyDelete
  6. This is useful content. really apreciate it!Great post....such a brilliant and mindful post Please Visit Our Webpage:
    http://thebusinessplace.in/
    http://thebusinessplace.in/packers-and-movers-adivare-pune
    For contacting us u may not need to call and spend money. Keeping in mind the customers convenience alternate chat enquiry option is added to website. At the right corner you can leave enquiry anytime for further information about the shifting services we provide. Movers And Packers Pune service operator will provide you with the information required via chat or will call you as per your suitability. Even u can Call us to 24x7 available services on 7023102310.

    ReplyDelete
  7. This is useful content. really apreciate it! Please Visit Our Webpage:
    http://thebusinessplace.in/
    http://thebusinessplace.in/packers-and-movers-adivare-pune
    For contacting us u may not need to call and spend money. Keeping in mind the customers convenience alternate chat enquiry option is added to website. At the right corner you can leave enquiry anytime for further information about the shifting services we provide. Movers And Packers Pune service operator will provide you with the information required via chat or will call you as per your suitability. Even u can Call us to 24x7 available services.

    ReplyDelete
  8. Thanks for sharing such a great article and it’s helpful for everyone. Great Post..
    http://packersmoversbangalore.in/

    ReplyDelete
  9. Thanks for sharing such a great article and it’s helpful for everyone. Great Post..
    http://packersmoversbangalore.in/

    ReplyDelete
  10. I must say you had done a tremendous job,I appreciate all your efforts.Thanks alot for your writings......Waiting for a new 1...Please visit our wonderful and valuable website-
    http://packersmoverschennai.in/
    http://packersmoverschennai.in/packers-and-movers-indian-institute-of-technology-chennai
    http://packersmoverschennai.in/packers-and-movers-mambalam-r-s-chennai
    http://packersmoverschennai.in/packers-and-movers-indian-institute-of-technology-chennai

    ReplyDelete
  11. I must say you had done a tremendous job,I appreciate all your efforts.Thanks alot for your writings......Waiting for a new 1...Please visit our wonderful and valuable website-
    http://packersmoverschennai.in/
    http://packersmoverschennai.in/packers-and-movers-indian-institute-of-technology-chennai
    http://packersmoverschennai.in/packers-and-movers-mambalam-r-s-chennai
    http://packersmoverschennai.in/packers-and-movers-indian-institute-of-technology-chennai

    ReplyDelete
  12. Top Packers And Movers Kolkata labors are trustworthy and answerable to us. Don’t worry about the fraud or any kind of theft in the relocating process. During the whole journey, in the pathway our local vendors check to ensure the safety of the customer’s good till it gets deliver to its owner.
    http://kolkatapackersmovers.in/
    http://kolkatapackersmovers.in/packers-and-movers-bartala-kolkata

    ReplyDelete
  13. A good informative post that you have shared and appreciate your work for sharing the information.....!!
    Packers and Movers Kolkata, Local Shifting Relocation and Top Movers Packers Kolkata. Packers and Movers Kolkata Household @ www.KolkataPackersMovers.in
    http://kolkatapackersmovers.in/
    http://kolkatapackersmovers.in/packers-and-movers-behala-kolkata

    ReplyDelete
  14. Generally I don’t read article on blogs, but I would like to say that this write-up very compelled me to take
    a look at and do so! Your writing style has been amazed me.
    Thank you, very great post.
    .Please visit our wonderful and valuable website-http://packersmovershyderabadcity.in/
    http://blog.packersmovershyderabadcity.in/

    ReplyDelete
  15. Generally I don’t read article on blogs, but I would like to say that this write-up very compelled me to take
    a look at and do so! Your writing style has been amazed me.
    Thank you, very great post.
    .Please visit our wonderful and valuable website-http://packersmovershyderabadcity.in/
    http://blog.packersmovershyderabadcity.in/

    ReplyDelete
  16. http://zetaclear2014.weebly.com/
    http://venapro2014.weebly.com/
    http://breast-actives.hpage.com/
    http://breastactives-us.weebly.com/
    http://tinnituscontrol2014.weebly.com/
    http://idollash2014.weebly.com/
    http://breastactivesb.weebly.com/
    http://xtremeno2014.weebly.com/
    http://eazol2014.weebly.com/
    http://xtremeno-us.weebly.com/
    http://idollash-us.weebly.com/
    http://buy-breast-actives.weebly.com/
    http://hghenergizer2014.weebly.com/
    http://tinnituscontrol-us.weebly.com/
    http://breastactivesresultsr.webs.com/
    http://zetaclear-us.weebly.com/
    http://hghenergizer-us.weebly.com/
    http://wartrol-us.weebly.com/
    http://breastactivesbuycheap.page.tl/
    http://venapro-us.weebly.com/

    ReplyDelete
  17. Get a wide range of packing and moving companies at helloenquiry.in. We endeavour to furnish the best packers and movers companies in Patna at ease of Internet. Packers and Movers Patna

    ReplyDelete
  18. Packers Movers Mumbai are one of the leading packers and movers. Movers And Packers Mumbai are offering our services not only in Mumbai but also other major cities of India.Movers engaged in packing, loading and unloading, transportation/moving, car transportation, warehousing, Packing And Moving services in India.
    http://packersmoversmumbaicity.in/

    ReplyDelete
  19. I really enjoyed reading your blog, you have lots of great content.Please visit here:
    http://bhubaneswarpackersmovers.in/
    We are expert in Handling, Movers And Packers Bhubaneswar and Packing & Shifting of Household Goods, Office goods, Commercial Equipment and Car, Logistics and Transportation.

    ReplyDelete
  20. i must say you had done a tremendous job,I appreciate all your efforts.Thanks alot for your writings......Waiting for a new 1..
    Packers And Movers Bhopal
    http://packersmoversbhopal.in/packers-and-movers-indore

    ReplyDelete
  21. Hello my friend! I want to say that this post is awesome, great written and include almost all
    important infos.I really love this post I will visit again to read your post in a very short time and I hope you will make more posts like this.

    T H A N K S
    F O R
    S H A R I N G

    WinAVI Video Converter 11.5 Keygen
    Trend Micro Antivirus
    Movie Converter 7 Keygen
    Neuratron Audio Score Ultimate Keygen

    ReplyDelete
  22. This is one of the fastest and most effective results among the existing diet pills.For More Information Visit: http://www.dietreviewmonster.com/phen375

    ReplyDelete
  23. http://greencoffeebeanmaxorder.com/
    Learn How Green Coffee Bean Max Extract can help slimmers lose excess body fat in a healthy and quick way without any negative side effects and buy online.

    ReplyDelete
  24. Click To read all Phen375 reviews, how does it work and what are it's benefits? Real testimonials from customers who used it. http://www.phen375online2016.com/

    ReplyDelete
  25. Dianabol Anabolic Steroids for Sale - Why Do Guys Consider Dianabol the Best Anabolic Steroids for Sale Online. http://www.dbalmax-reviews.com/

    ReplyDelete
  26. "Does Forskolin Fuel works for everyone?
    Yes, a natural, yet potent weight loss agent like forskolin fuel would work for every single person looking forward for weight reduction. It is said to be the ultimate diet pills that have and have been shaping the bodies of many, living all over the globe.
    For more Information Visit: http://www.forskolinfuel-reviews.com/ ,

    Forskolin fuel


    Forskolin fuel


    Forskolin fuel


    Forskolin fuel


    Forskolin fuel


    Forskolin fuel


    Forskolin fuel


    Forskolin fuel


    Forskolin fuel


    Forskolin fuel


    Forskolin fuel


    Forskolin fuel
    "

    ReplyDelete
  27. Dianabol Anabolic Steroids for Sale - Why Do Guys Consider Dianabol the Best Anabolic Steroids for Sale Online. http://www.dbalmax-reviews.com/

    ReplyDelete
  28. Breast Actives
    is a 3 step all natural solution for breast enlargement, combining breast pills, cream and a breast exercise and massage program.http://www.breastactivesbuy.com/

    ReplyDelete
  29. Jobs Chat is one of the biggest Indian Job Site so here you will getAll Government jobs Syllabusso

    ReplyDelete
  30. I have discovered It positively useful and it has aided me out loads. I am hoping to contribute & aid different users like its helped me. Great job.
    Perfume Day
    Kick Day
    Promise Day
    Teddy Day
    Rose Day
    Chocolate Day
    Teddy Day
    Propose Day
    holi images

    ReplyDelete
  31. Exclusive Collection of Salwar Suit And Many More….
    We Have Some For You In Your Budget For more….
    Eid Mubarak Wishes

    ReplyDelete
  32. Fancy designer wear our website and reasonable price More…
    We Have Some For You In Your Budget For more…
    Plz visit:- Designer Lehenga

    ReplyDelete
  33. Mother's Day is a celebration in regards to the mother of the family, and furthermore parenthood, maternal bonds, and the effect of mothers in the general population field. It is commended on various days in many parts of the world, most routinely in the seasons of February or normal of the week. happymothersdaymessages It supplements near celebrations with respect to relatives, for instance, Father's Day and Siblings Day.
    https://en.wikipedia.org/wiki/Mother

    ReplyDelete
  34. Best Outfits For Young ladies,Womens and Girls
    We Have Some For You In Your Budget For more…
    Plz visit:- Punjabi Suit

    ReplyDelete
  35. Exclusive Collection of Salwar Suit and Many More…
    We Have Some For You In Your Budget For more…
    Plz visit:- Designer Anarkali salwar kameez


    ReplyDelete
  36. Thank you for the useful information. You might be interested in CCI Syllabus

    ReplyDelete
  37. Designer clothes have taken the world by storm with its ethnic patterns and stylish designs. The Indian salwar suits are popular all across the world for its rich fabrics and diverse patterns. It has ruled the Indian fashion world for many decades. for more...
    Plz visit:- Ladies Suits

    ReplyDelete
  38. The Punjabi suit is the traditional dress of women in the Punjab region.
    It is made up of a kurta or kameez and a straight cut salwar.
    In some parts of the Punjab region, men also wear the Punjabi suit.
    Plz visit:- PunjabiSuit

    ReplyDelete
  39. You can get a Amazing variety of bridal dresses at our sites.
    The dresses are very beautiful to look at and you can pick them up from online shops.
    we have some for you in your budget...
    Bridal Dresses

    ReplyDelete
  40. You can buy from our large and diverse collection of salwar kameez, party wear suits, Bollywood collection, cotton Kurtis, Anarkali suits, Bollywood saree and many other products.....
    We Have Some For You In Your Budget For more…
    Plz visit:- Gown

    ReplyDelete
  41. India is the country of culture Festival.People in india are so crazy about festivals.Diwali is the biggest festival of India.It is the Festival Of Lights.
    Christmas is the New Year of Christians.
    Plz visit:- Happy Diwali Images
    Merry Christmas Wishes
    Happy New Year 2017

    ReplyDelete
  42. India is a land of varied culture and religion and throughout the year a series of interesting events and festivals take place here. So, it can be expected that if you will ever visit India you will get opportunity to enjoy at least a few such occasions.
    Happy Diwali Status
    Merry Christmas Images
    Happy New Year Wishes

    ReplyDelete
  43. Kurtis,Salwar Suit, Saree, Gown, Anarkali Suit online shopping at Stylizone will not disappoint you as it is India's best designer wear selling outlet. visit us at Stylizone and enjoy best quality, stylish products at the best prices.
    Lehenga
    Sarees
    Gown
    Bridal Lehenga
    Pakistani Dress
    Designer Sarees
    Wedding Lehenga
    Salwar Kameez
    Salwar Suit
    Anarkali Suit

    ReplyDelete

  44. You can buy Lehenga, Patiala salwar suits,Anarkali Suit, Gown, Salwar Suit, Saree and get an exquisite design for you. There is something for everyone here. We even offer customized tailoring. Visit at..
    Anarkali Dress
    Punjabi Dress
    Wedding Saree
    Lehenga Choli
    Ghagra Choli
    Silk Saree
    Ladies Suit
    Indian Saree
    Designer Dress
    Bridal Dresses

    ReplyDelete
  45. The Contemporary style of Punjabi suits exclusively available on Stylizone does offer picturesque of luxury, royalty and elegance. Be it flaring or twirling Ghera dress, with the simple clicks thousand of new styles and patterns are available.
    Punjabi Suits
    Designer Kurtis
    Kurtis
    Wedding Dress
    Lehenga
    Saree
    Gown
    Bridal Lehenga
    Pakistani Dress
    Designer Saree

    ReplyDelete
  46. According to festivities and Seasons, the exemplary styles of fabric do make a heart throbbing impressions in the minds of wearer. We have Lehenga, Wedding Gown visit at..
    Wedding Lehenga
    Salwar Kameez
    Salwar Suit
    Anarkali Suit
    Anarkali Dress
    Punjabi Dress
    Wedding Saree
    Lehenga Choli
    Ghagra Choli
    Silk Saree

    ReplyDelete
  47. Designer clothes are the reflection of personality of a person. It's very necessary to choose the wear according to an ocassion. In India,Designer Bridal Saree are the most obvious choice for the Young Ladies & Girls. Many more Collection is available at our site. For More....
    Ladies Suit
    Indian Saree
    Designer Dress
    Bridal Dress
    Kurti
    Designer Kurti
    Wedding Dresss
    Punjabi Suit

    ReplyDelete