Repository: pytest-dev/pytest
File: src/_pytest/config/__init__.py (Python)

Code before:
        modules or packages in the distribution package for
        all pytest plugins."""
        self.pluginmanager.rewrite_hook = hook

        if os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD"):
            # We don't autoload from distribution package entry points,
            # no need to continue.
            return

        package_files = (
            str(file)
            for dist in importlib.metadata.distributions()
            if any(ep.group == "pytest11" for ep in dist.entry_points)
            for file in dist.files or []
        )

        for name in _iter_rewritable_modules(package_files):
            hook.mark_rewrite(name)

    def _configure_python_path(self):
        # `pythonpath = a b` will set `sys.path` to `[a, b, x, y, z, ...]`
        for path in reversed(self.getini("pythonpath")):
            sys.path.insert(0, str(path))
        self.add_cleanup(self._unconfigure_python_path)

    def _unconfigure_python_path(self):
        for path in self.getini("pythonpath"):
            path_str = str(path)
            if path_str in sys.path:
                sys.path.remove(path_str)

    def _validate_args(self, args: list[str], via: str) -> list[str]:
        """Validate known args."""
        self._parser._config_source_hint = via  # type: ignore
        try:
            self._parser.parse_known_and_unknown_args(
                args, namespace=copy.copy(self.option)
            )
        finally:
            del self._parser._config_source_hint  # type: ignore

        return args

    def _decide_args(
        self,
        *,
        args: list[str],
        pyargs: bool,
        testpaths: list[str],
        invocation_dir: pathlib.Path,
        rootpath: pathlib.Path,

Review comment (suggestion):
~~This is not being called?~~ Sorry missed it.



```suggestion
    def _unconfigure_python_path(self) -> None:
```

Code after:
        modules or packages in the distribution package for
        all pytest plugins."""
        self.pluginmanager.rewrite_hook = hook

        if os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD"):
            # We don't autoload from distribution package entry points,
            # no need to continue.
            return

        package_files = (
            str(file)
            for dist in importlib.metadata.distributions()
            if any(ep.group == "pytest11" for ep in dist.entry_points)
            for file in dist.files or []
        )

        for name in _iter_rewritable_modules(package_files):
            hook.mark_rewrite(name)

    def _configure_python_path(self) -> None:
        # `pythonpath = a b` will set `sys.path` to `[a, b, x, y, z, ...]`
        for path in reversed(self.getini("pythonpath")):
            sys.path.insert(0, str(path))
        self.add_cleanup(self._unconfigure_python_path)

    def _unconfigure_python_path(self) -> None:
        for path in self.getini("pythonpath"):
            path_str = str(path)
            if path_str in sys.path:
                sys.path.remove(path_str)

    def _validate_args(self, args: list[str], via: str) -> list[str]:
        """Validate known args."""
        self._parser._config_source_hint = via  # type: ignore
        try:
            self._parser.parse_known_and_unknown_args(
                args, namespace=copy.copy(self.option)
            )
        finally:
            del self._parser._config_source_hint  # type: ignore

        return args

    def _decide_args(
        self,
        *,
        args: list[str],
        pyargs: bool,
        testpaths: list[str],
        invocation_dir: pathlib.Path,
        rootpath: pathlib.Path,