# Buggy code
def handle(self, *args, **options):
    self.style = color_style()

    self.options = options
    if options["requirements"]:
        req_files = options["requirements"]
    elif os.path.exists("requirements.txt"):
        req_files = ["requirements.txt"]
    elif os.path.exists("requirements"):
        req_files = [
            "requirements/{0}".format(f)
            for f in os.listdir("requirements")
            if os.path.isfile(os.path.join("requirements", f))
            and f.lower().endswith(".txt")
        ]
    elif os.path.exists("requirements-dev.txt"):
        req_files = ["requirements-dev.txt"]
    elif os.path.exists("requirements-prod.txt"):
        req_files = ["requirements-prod.txt"]
    else:
        raise CommandError("Requirements file(s) not found")

    self.reqs = {}
    with PipSession() as session:
        for filename in req_files:
            for req in parse_requirements(filename, session=session):
                # url attribute changed to link in pip version 6.1.0 and above
                if LooseVersion(pip.__version__) > LooseVersion("6.0.8"):
                    self.reqs[req.name] = {
                        "pip_req": req,
                        "url": req.link,
                    }
                else:
                    self.reqs[req.name] = {
                        "pip_req": req,
                        "url": req.url,
                    }

    if options["github_api_token"]:
        self.github_api_token = options["github_api_token"]
    elif os.environ.get("GITHUB_API_TOKEN"):
        self.github_api_token = os.environ.get("GITHUB_API_TOKEN")
    else:
        self.github_api_token = None  # only 50 requests per hour

    self.check_pypi()
    if HAS_REQUESTS:
        self.check_github()
    else:
        print(
            self.style.ERROR(
                "Cannot check github urls. The requests library is not installed. ( pip install requests )"
            )
        )
    self.check_other()


# 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 handle(self, *args, **options):
    self.style = color_style()

    self.options = options
    if options["requirements"]:
        req_files = options["requirements"]
    elif os.path.exists("requirements.txt"):
        req_files = ["requirements.txt"]
    elif os.path.exists("requirements"):
        req_files = [
            "requirements/{0}".format(f)
            for f in os.listdir("requirements")
            if os.path.isfile(os.path.join("requirements", f))
            and f.lower().endswith(".txt")
        ]
    elif os.path.exists("requirements-dev.txt"):
        req_files = ["requirements-dev.txt"]
    elif os.path.exists("requirements-prod.txt"):
        req_files = ["requirements-prod.txt"]
    else:
        raise CommandError("Requirements file(s) not found")

    self.reqs = {}
    with PipSession() as session:
        for filename in req_files:
            for req in parse_requirements(filename, session=session):
                name = req.name if req.name else req.link.filename
                # url attribute changed to link in pip version 6.1.0 and above
                if LooseVersion(pip.__version__) > LooseVersion("6.0.8"):
                    self.reqs[name] = {
                        "pip_req": req,
                        "url": req.link,
                    }
                else:
                    self.reqs[name] = {
                        "pip_req": req,
                        "url": req.url,
                    }

    if options["github_api_token"]:
        self.github_api_token = options["github_api_token"]
    elif os.environ.get("GITHUB_API_TOKEN"):
        self.github_api_token = os.environ.get("GITHUB_API_TOKEN")
    else:
        self.github_api_token = None  # only 50 requests per hour

    self.check_pypi()
    if HAS_REQUESTS:
        self.check_github()
    else:
        self.stdout.write(
            self.style.ERROR(
                "Cannot check github urls. The requests library is not installed. ( pip install requests )"
            )
        )
    self.check_other()