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

Code before:
        self.hook.pytest_addoption.call_historic(
            kwargs=dict(parser=self._parser, pluginmanager=self.pluginmanager)
        )
        self.args_source = Config.ArgsSource.ARGS
        self.args: list[str] = []

    @property
    def rootpath(self) -> pathlib.Path:
        """The path to the :ref:`rootdir <rootdir>`.

        :type: pathlib.Path

        .. versionadded:: 6.1
        """
        return self._rootpath

    @property
    def inipath(self) -> pathlib.Path | None:
        """The path to the :ref:`configfile <configfiles>`.

        .. versionadded:: 6.1
        """
        return self._inipath

    @property
    def should_warn(self) -> bool:
        """Whether a warning should be emitted for the configuration.

        .. versionadded:: 8.6
        """
        return self._should_warn

    def add_cleanup(self, func: Callable[[], None]) -> None:
        """Add a function to be called when the config object gets out of
        use (usually coinciding with pytest_unconfigure).
        """
        self._cleanup_stack.callback(func)

    def _do_configure(self) -> None:
        assert not self._configured
        self._configured = True
        self.hook.pytest_configure.call_historic(kwargs=dict(config=self))

    def _ensure_unconfigure(self) -> None:
        try:
            if self._configured:
                self._configured = False
                try:
                    self.hook.pytest_unconfigure(config=self)
                finally:
                    self.hook.pytest_configure._call_history = []

Review comment (suggestion):
Thanks for the update.
 
- We shouldn't expose this in the public API, let's keep it private unless there's a need.
 
- If it's private, no need for a property
 
- The name `should_warn` is too generic, we should say warn about what. Or better, something like `_ignored_config_files = ["pyproject.toml", ".pytest.ini']` containing the ignored files we detected. Semantically whether or not to warn is up to the place which warns.

Code after:
        self.hook.pytest_addoption.call_historic(
            kwargs=dict(parser=self._parser, pluginmanager=self.pluginmanager)
        )
        self.args_source = Config.ArgsSource.ARGS
        self.args: list[str] = []

    @property
    def rootpath(self) -> pathlib.Path:
        """The path to the :ref:`rootdir <rootdir>`.

        :type: pathlib.Path

        .. versionadded:: 6.1
        """
        return self._rootpath

    @property
    def inipath(self) -> pathlib.Path | None:
        """The path to the :ref:`configfile <configfiles>`.

        .. versionadded:: 6.1
        """
        return self._inipath

    def add_cleanup(self, func: Callable[[], None]) -> None:
        """Add a function to be called when the config object gets out of
        use (usually coinciding with pytest_unconfigure).
        """
        self._cleanup_stack.callback(func)

    def _do_configure(self) -> None:
        assert not self._configured
        self._configured = True
        self.hook.pytest_configure.call_historic(kwargs=dict(config=self))

    def _ensure_unconfigure(self) -> None:
        try:
            if self._configured:
                self._configured = False
                try:
                    self.hook.pytest_unconfigure(config=self)
                finally:
                    self.hook.pytest_configure._call_history = []
        finally:
            try:
                self._cleanup_stack.close()
            finally:
                self._cleanup_stack = contextlib.ExitStack()

    def get_terminal_writer(self) -> TerminalWriter:
        terminalreporter: TerminalReporter | None = self.pluginmanager.get_plugin(