summaryrefslogtreecommitdiff
path: root/pylint/pyreverse
diff options
context:
space:
mode:
authorAlexey Pelykh <alexey.pelykh@gmail.com>2023-02-09 20:16:02 +0100
committerGitHub <noreply@github.com>2023-02-09 20:16:02 +0100
commit71b6325c8499c8a66e90d90e88c75d7c7ab13b23 (patch)
tree5469f59cc6762feef6721f57f71d84f56ed81bb2 /pylint/pyreverse
parent70e2178dcaecdc4e90ac1cb45e06be261bd1e03b (diff)
downloadpylint-git-71b6325c8499c8a66e90d90e88c75d7c7ab13b23.tar.gz
Support Implicit Namespace Packages (PEP 420) (#8153)
Co-authored-by: Andreas Finkler <3929834+DudeNr33@users.noreply.github.com>
Diffstat (limited to 'pylint/pyreverse')
-rw-r--r--pylint/pyreverse/main.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py
index 8a2055c41..13669d5b4 100644
--- a/pylint/pyreverse/main.py
+++ b/pylint/pyreverse/main.py
@@ -13,7 +13,8 @@ from typing import NoReturn
from pylint import constants
from pylint.config.arguments_manager import _ArgumentsManager
from pylint.config.arguments_provider import _ArgumentsProvider
-from pylint.lint.utils import fix_import_path
+from pylint.lint import discover_package_path
+from pylint.lint.utils import augmented_sys_path
from pylint.pyreverse import writer
from pylint.pyreverse.diadefslib import DiadefsHandler
from pylint.pyreverse.inspector import Linker, project_from_files
@@ -203,6 +204,17 @@ OPTIONS: Options = (
"help": "set the output directory path.",
},
),
+ (
+ "source-roots",
+ {
+ "type": "paths_csv",
+ "metavar": "<path>[,<path>...]",
+ "default": (),
+ "help": "Add paths to the list of the source roots. The source root is an absolute "
+ "path or a path relative to the current working directory used to "
+ "determine a package namespace for modules located under the source root.",
+ },
+ ),
)
@@ -235,7 +247,10 @@ class Run(_ArgumentsManager, _ArgumentsProvider):
if not args:
print(self.help())
return 1
- with fix_import_path(args):
+ extra_packages_paths = list(
+ {discover_package_path(arg, self.config.source_roots) for arg in args}
+ )
+ with augmented_sys_path(extra_packages_paths):
project = project_from_files(
args,
project_name=self.config.project,