Merge eb0276c3cb390976216c4a054d4b6769f67d53a7 into 90102acdbb23c09574d27df8bd1f568d34e0cfd3

This commit is contained in:
spenly 2021-05-07 07:33:31 +02:00 committed by GitHub
commit 898473aae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 18 deletions

View File

@ -3,6 +3,11 @@
History
-------
0.4.9 (2018-03-14)
--------------------
* Add to show imported but not declared requirements for '--diff' (spenly)
0.4.8 (2017-06-30)
--------------------

View File

@ -24,7 +24,7 @@ Installation
::
pip install pipreqs
pip install pipreqs-spenly
Usage
-----

View File

@ -352,17 +352,26 @@ def compare_modules(file_, imports):
imports = [imports[i]["name"] for i in range(len(imports))]
modules = [modules[i]["name"] for i in range(len(modules))]
modules_not_imported = set(modules) - set(imports)
return modules_not_imported
modules_not_declared = set(imports) - set(modules)
return modules_not_imported, modules_not_declared
def diff(file_, imports):
"""Display the difference between modules in a file and imported modules.""" # NOQA
modules_not_imported = compare_modules(file_, imports)
modules_not_imported, modules_not_declared = compare_modules(file_, imports)
if modules_not_imported:
logging.info(
"The following modules are in {} but do not seem to be imported: "
"The following modules are in {} but do not seem to be imported: \n"
"{}".format(file_, ", ".join(x for x in modules_not_imported)))
else:
logging.info("No module is in {} but do not seem to be imported.".format(file_))
if modules_not_declared:
logging.info(
"The following modules are not in {} but seem to be imported: \n"
"{}".format(file_, ", ".join(x for x in modules_not_declared)))
else:
logging.info("No module is not in {} but seem to be imported:.".format(file_))
def clean(file_, imports):

View File

@ -21,7 +21,7 @@ requirements = [
]
setup(
name='pipreqs',
name='pipreqs-spenly',
version=__version__,
description='Pip requirements.txt generator based on imports in project',
long_description=readme + '\n\n' + history,