Second Request, Please Reconsider

Suffering with the aftermath of my unsuccessful attempt at fixing a bug, I stayed away from Open Source for almost a week. It gave me some rest to begin afresh and rejuvenated to earn that t-shirt. The grades. No, that experience.

For motivation ( and to secretly lament myself) I went to the course wiki to see what my classmates had done. I found one of them had contributed to Python Packaging Authority (pypa). Sounds intimidating, right?

As I was looking around at different projects, bandersnatch caught my attention. It is a tool that can be used by enterprises to keep mirrors of all pip packages on their network in order to make pip install faster through local indexing.

I found the perfect bug, one regarding type checking in the main python script. The project is a command line tool so it heavily relies on the argparse module. To have modularity in parsing, the parser was split into subparsers. For each of the subparsers, they had a function which accepted an argument of this subparser type. They were using Any as the parameter type, which is very generic.

So I did some research and found out that they could use a private object type called ._SubParsersAction which is returned when a subparser is created. Here is my pull request that does the same.

I have heard at many occasions that python is not a great language at times because it is too flexible with type checking. But PEP484 introduces type hinting for python. And it is very promising. You can use a library like mypy to check static typing before your code compilation. It is basically a linting feature.

I also had to present my research to the reviewer.

This PR was a good learning experience for me as I got involved in an exciting project and also refreshed my parsing knowledge for python. I am back!

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store