mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-12 15:27:14 +03:00
Bring in scripts/pip_rev_deps.py
* This finds the pip-installed modules that depend on the specified module. Handy for cleaning things up. * Leads to needing types-pkg-resources for mypy (and via pre-commit).
This commit is contained in:
parent
bc5cb48f8c
commit
5064b10744
@ -51,7 +51,7 @@ repos:
|
||||
- id: mypy
|
||||
# verbose: true
|
||||
# log_file: 'pre-commit_mypy.log'
|
||||
additional_dependencies: [ types-requests, types-urllib3 ]
|
||||
additional_dependencies: [ types-pkg-resources, types-requests, types-urllib3 ]
|
||||
# args: [ "--follow-imports", "skip", "--ignore-missing-imports", "--scripts-are-modules" ]
|
||||
|
||||
### # pydocstyle.exe <file>
|
||||
|
@ -24,6 +24,7 @@ mypy==0.991
|
||||
pep8-naming==0.13.3
|
||||
safety==2.3.5
|
||||
types-requests==2.28.11.7
|
||||
types-pkg-resources==0.1.3
|
||||
|
||||
# Code formatting tools
|
||||
autopep8==2.0.1
|
||||
|
22
scripts/pip_rev_deps.py
Normal file
22
scripts/pip_rev_deps.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
"""Find the reverse dependencies of a package according to pip."""
|
||||
import sys
|
||||
|
||||
import pkg_resources
|
||||
|
||||
|
||||
def find_reverse_deps(package_name: str):
|
||||
"""
|
||||
Find the packages that depend on the named one.
|
||||
|
||||
:param package_name: Target package.
|
||||
:return: List of packages that depend on this one.
|
||||
"""
|
||||
return [
|
||||
pkg.project_name for pkg in pkg_resources.WorkingSet()
|
||||
if package_name in {req.project_name for req in pkg.requires()}
|
||||
]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(find_reverse_deps(sys.argv[1]))
|
Loading…
x
Reference in New Issue
Block a user