# Buggy code
def check_pypi(self):
    """
    If the requirement is frozen to pypi, check for a new version.
    """
    for dist in get_installed_distributions():
        name = dist.project_name
        if name in self.reqs.keys():
            self.reqs[name]["dist"] = dist

    pypi = ServerProxy("https://pypi.python.org/pypi")
    for name, req in list(self.reqs.items()):
        if req["url"]:
            continue  # skipping github packages.
        elif "dist" in req:
            dist = req["dist"]
            dist_version = LooseVersion(dist.version)
            available = pypi.package_releases(
                req["pip_req"].name, True
            ) or pypi.package_releases(req["pip_req"].name.replace("-", "_"), True)
            available_version = self._available_version(dist_version, available)

            if not available_version:
                msg = self.style.WARN(
                    "release is not on pypi (check capitalization and/or --extra-index-url)"
                )
            elif self.options["show_newer"] and dist_version > available_version:
                msg = self.style.INFO(
                    "{0} available (newer installed)".format(available_version)
                )
            elif available_version > dist_version:
                msg = self.style.INFO("{0} available".format(available_version))
            else:
                msg = "up to date"
                del self.reqs[name]
                continue
            pkg_info = self.style.BOLD(
                "{dist.project_name} {dist.version}".format(dist=dist)
            )
        else:
            msg = "not installed"
            pkg_info = name
        print("{pkg_info:40} {msg}".format(pkg_info=pkg_info, msg=msg))
        del self.reqs[name]


# Traceback (TypeError)
Package                       Version
----------------------------- ----------
django-extensions             2.1.3

$ cat r.txt
git+https://github.com/jmrivas86/django-json-widget

$ venv/bin/python -B manage.py pipchecker -r r.txt
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File ".../venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File ".../venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File ".../venv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File ".../venv/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File ".../venv/lib/python3.6/site-packages/django_extensions/management/utils.py", line 59, in inner
ret = func(self, *args, **kwargs)
File ".../venv/lib/python3.6/site-packages/django_extensions/management/commands/pipchecker.py", line 109, in handle
self.check_github()
File ".../venv/lib/python3.6/site-packages/django_extensions/management/commands/pipchecker.py", line 294, in check_github
print("{pkg_info:40} {msg}".format(pkg_info=pkg_info, msg=msg))
TypeError: unsupported format string passed to NoneType.__format__

# Fixed code
def check_pypi(self):
    """
    If the requirement is frozen to pypi, check for a new version.
    """
    for dist in get_installed_distributions():
        name = dist.project_name
        if name in self.reqs.keys():
            self.reqs[name]["dist"] = dist

    pypi = ServerProxy("https://pypi.python.org/pypi")
    for name, req in list(self.reqs.items()):
        if req["url"]:
            continue  # skipping github packages.
        elif "dist" in req:
            dist = req["dist"]
            dist_version = LooseVersion(dist.version)
            available = pypi.package_releases(
                req["pip_req"].name, True
            ) or pypi.package_releases(req["pip_req"].name.replace("-", "_"), True)
            available_version = self._available_version(dist_version, available)

            if not available_version:
                msg = self.style.WARN(
                    "release is not on pypi (check capitalization and/or --extra-index-url)"
                )
            elif self.options["show_newer"] and dist_version > available_version:
                msg = self.style.INFO(
                    "{0} available (newer installed)".format(available_version)
                )
            elif available_version > dist_version:
                msg = self.style.INFO("{0} available".format(available_version))
            else:
                msg = "up to date"
                del self.reqs[name]
                continue
            pkg_info = self.style.BOLD(
                "{dist.project_name} {dist.version}".format(dist=dist)
            )
        else:
            msg = "not installed"
            pkg_info = name
        self.stdout.write("{pkg_info:40} {msg}".format(pkg_info=pkg_info, msg=msg))
        del self.reqs[name]