Local import of docopt

Allows better usage of pipreqs as a library

Signed-off-by: Oz Tiram <oz.tiram@gmail.com>
This commit is contained in:
Oz Tiram 2025-04-08 19:46:31 +02:00
parent 2ef6a981d5
commit 126b625004
No known key found for this signature in database
GPG Key ID: DA92A52CE3045C41
2 changed files with 9 additions and 2 deletions

View File

@ -44,7 +44,6 @@ import re
import logging import logging
import ast import ast
import traceback import traceback
from docopt import docopt
import requests import requests
from yarg import json2package from yarg import json2package
from yarg.exceptions import HTTPError from yarg.exceptions import HTTPError
@ -602,6 +601,11 @@ def init(args):
def main(): # pragma: no cover def main(): # pragma: no cover
try:
from docopt import docopt
except (ImportError, ModuleNotFoundError):
sys.exit("Please install docopt to use the command line")
args = docopt(__doc__, version=__version__) args = docopt(__doc__, version=__version__)
log_level = logging.DEBUG if args["--debug"] else logging.INFO log_level = logging.DEBUG if args["--debug"] else logging.INFO
logging.basicConfig(level=log_level, format="%(levelname)s: %(message)s") logging.basicConfig(level=log_level, format="%(levelname)s: %(message)s")

View File

@ -28,7 +28,6 @@ classifiers = [
requires-python = ">=3.9, <3.14" requires-python = ">=3.9, <3.14"
dependencies = [ dependencies = [
"yarg>=0.1.9", "yarg>=0.1.9",
"docopt>=0.6.2",
"nbconvert>=7.11.0", "nbconvert>=7.11.0",
"ipython>=8.12.3", "ipython>=8.12.3",
] ]
@ -39,6 +38,10 @@ dev = [
"coverage>=7.3.2", "coverage>=7.3.2",
"sphinx>=7.2.6;python_version>='3.9'", "sphinx>=7.2.6;python_version>='3.9'",
] ]
cli = [
"docopt>=0.6.2",
]
[tool.poetry.group.dev.dependencies] # for legacy usage [tool.poetry.group.dev.dependencies] # for legacy usage
flake8 = "^6.1.0" flake8 = "^6.1.0"
tox = "^4.11.3" tox = "^4.11.3"