OpenBazaar/OpenBazaar — pull request #621 by Renelvon (2014-09-19 17:15:59+00:00)
Title: [WIP] Accept the pylint challenge.

### Motivation:
As a security project, we need a lot of safety checks on our code. Python being dynamically typed and interpreted, there is no "compiler" to warn us of any errors. We don't want to give up on Python, so what do we do?

We install [pylint](http://www.pylint.org/) on the build.

### Usage guide
Pylint is probably the most advanced and actively maintained [static analysis](https://en.wikipedia.org/wiki/Static_program_analysis) tool for python. It ships with a wide range of [code checkers](http://docs.pylint.org/features.html), accepts [plugins](http://docs.pylint.org/plugins.html), and can be [selectively silenced](http://docs.pylint.org/message-control.html). I *urge* you to [integrate](http://docs.pylint.org/ide-integration.html) it with your IDE and consult it systematically. It is surprising how much python can one learn just by reading and fixing the pylint errors!

Pylint has 5 main types of errors:
* __F__ for fatal errors happening during analysis.
* __E__ for programming errors
* __W__ for important warnings
* __C__ for convention violations
* __R__ for refactoring suggestions

Obviously, any errors of type __F__ or __E__ should be fixed as soon as possible. Warnings (__W__) shouldn't be glossed over. Conventions (__C__) shouldn't be broken without due reason (this includes PEP8 violations). Refactoring suggestions (__R__) should be taken in consideration; not many are currently enabled, but they are important. Occasionally, pylint may flag correct code. If you are *absolutely serious* this is the case, please silence the warning with an appropriate pylint comment and include a reference to the silencing in the commit message.

### Roadmap
Pylint is so verbose with its warnings, errors and suggestions that it is not not usually meant to be run as a build-checker. However, the sensitive nature of our code demands that we do so. Since our codebase hasn't undergone any static analysis prior to this, unleashing Pylint on the repo with all the bells and whistles enabled would be pointless. The present PR fixes some errors and disables many switches that currently cause many errors, so that we don't break all existing PRs out there.

It is intended that the list of disabled errors gets smaller as time goes by and code gets straightened out. For a list of possible suggestions on what to do next, check the `.pylintrc` file against the [lmost-complete error list](http://docs.pylint.org/features.html).

In order to avoid confusion and double-reporting, `flake8` is disabled and removed from the build. Pylint is far superior and more comprehensive in almost all areas of interest. However, this doesn't mean that you should also remove `flake8` from your development cycle. `flake` can coexist with `pylint` except in rare cases where they can be mutually exclusive (mostly on enforcing PEP8). Use them both and exercise your judgement.

The above paragraph notwithstanding, release versions should be manually checked and errors be fixed against `flake8` by the contributor signing the tag.

### Notes:
* Pylint will make you write code that is much closer to the Python 3 standard (without violating the Python 2 standard, of course). For example, it will make you use explicit relative imports (W0403). This is intentional. We may or may not migrate our code to Python 3 eventually (see #619), but we certainly don't want to alienate future readers. These changes also have the added benefit of making the code a bit more self-documented. Please respect them.
* Pylint is a *bit* more lax on enforcing PEP8 standards. This means everyone can again use their favourite hanging indent style. [Enjoy](https://www.youtube.com/watch?v=WlBiLNN1NhQ).
* There is a number of *errors* that are currently disabled. This is mostly due to bad code residing in the `/features` directory. Whoever submitted the said code, please take a moment to fix it: Remove the errors from the disable list of `.pylintrc` and run `./checkstyle python`.

### Changelog:
* Install `pylint` on the build. Remove `flake8` for the time being. Also drop unused `coverage` package.
* Activate a selective menu of errors, warnings, coventions, refactorings and fatals. Disable any errors requiring heavy reafactoring for now.
* Fix all errors currently reported, so that build is clean.
* Create a `.pylintrc` file that contains pylint configuration.

Please review the changes and let me know if you find any of them unreasonable. I have split them across many commits for educational purposes; I will squash them before merging.