Path 1: 1397 calls (1.0)

PyLinter (1397)

'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint/checkers' (1137) '/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint...

1def register_plugins(linter: PyLinter, directory: str) -> None:
2    """Load all module and package in the given directory, looking for a
3    'register' function in each one, used to register pylint checkers.
4    """
5    imported = {}
6    for filename in os.listdir(directory):
7        base, extension = os.path.splitext(filename)
8        if base in imported or base == "__pycache__":
9            continue
10        if (
11            extension in PY_EXTS
12            and base != "__init__"
13            or (
14                not extension
15                and os.path.isdir(os.path.join(directory, base))
16                and not filename.startswith(".")
17            )
18        ):
19            try:
20                module = modutils.load_module_from_file(
21                    os.path.join(directory, filename)
22                )
23            except ValueError:
24                # empty module name (usually Emacs auto-save files)
25                continue
26            except ImportError as exc:
27                print(f"Problem importing module {filename}: {exc}", file=sys.stderr)
28            else:
29                if hasattr(module, "register"):
30                    module.register(linter)
31                    imported[base] = 1