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

Code before:
        self._parser.extra_info["rootdir"] = str(self.rootpath)
        self._parser.extra_info["inifile"] = str(self.inipath)
        self._parser.addini("addopts", "Extra command line options", "args")
        self._parser.addini("minversion", "Minimally required pytest version")
        self._parser.addini(
            "pythonpath", type="paths", help="Add paths to sys.path", default=[]
        )
        self._parser.addini(
            "required_plugins",
            "Plugins that must be present for pytest to run",
            type="args",
            default=[],
        )
        self._override_ini = ns.override_ini or ()

    def _consider_importhook(self, args: Sequence[str]) -> None:
        """Install the PEP 302 import hook if using assertion rewriting.

        Needs to parse the --assert=<mode> option from the commandline
        and find all the installed plugins to mark them for rewriting
        by the importhook.
        """
        ns, unknown_args = self._parser.parse_known_and_unknown_args(args)
        mode = getattr(ns, "assertmode", "plain")

        disable_autoload = getattr(ns, "disable_plugin_autoload", False) | bool(
            os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
        )
        if mode == "rewrite":
            import _pytest.assertion

            try:
                hook = _pytest.assertion.install_importhook(self)
            except SystemError:
                mode = "plain"
            else:
                self._mark_plugins_for_rewrite(hook, disable_autoload)
        self._warn_about_missing_assertion(mode)

    def _mark_plugins_for_rewrite(
        self, hook: AssertionRewritingHook, disable_autoload: bool
    ) -> None:
        """Given an importhook, mark for rewrite any top-level
        modules or packages in the distribution package for
        all pytest plugins."""
        self.pluginmanager.rewrite_hook = hook

        if disable_autoload:
            # We don't autoload from distribution package entry points,
            # no need to continue.
            return

Review comment (suggestion):
Let's use the standard comparison operator instead of the bit-wise one.

```suggestion
        disable_autoload = getattr(ns, "disable_plugin_autoload", False) or bool(
```

Code after:
        self._parser.extra_info["rootdir"] = str(self.rootpath)
        self._parser.extra_info["inifile"] = str(self.inipath)
        self._parser.addini("addopts", "Extra command line options", "args")
        self._parser.addini("minversion", "Minimally required pytest version")
        self._parser.addini(
            "pythonpath", type="paths", help="Add paths to sys.path", default=[]
        )
        self._parser.addini(
            "required_plugins",
            "Plugins that must be present for pytest to run",
            type="args",
            default=[],
        )
        self._override_ini = ns.override_ini or ()

    def _consider_importhook(self, args: Sequence[str]) -> None:
        """Install the PEP 302 import hook if using assertion rewriting.

        Needs to parse the --assert=<mode> option from the commandline
        and find all the installed plugins to mark them for rewriting
        by the importhook.
        """
        ns, unknown_args = self._parser.parse_known_and_unknown_args(args)
        mode = getattr(ns, "assertmode", "plain")

        disable_autoload = getattr(ns, "disable_plugin_autoload", False) or bool(
            os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
        )
        if mode == "rewrite":
            import _pytest.assertion

            try:
                hook = _pytest.assertion.install_importhook(self)
            except SystemError:
                mode = "plain"
            else:
                self._mark_plugins_for_rewrite(hook, disable_autoload)
        self._warn_about_missing_assertion(mode)

    def _mark_plugins_for_rewrite(
        self, hook: AssertionRewritingHook, disable_autoload: bool
    ) -> None:
        """Given an importhook, mark for rewrite any top-level
        modules or packages in the distribution package for
        all pytest plugins."""
        self.pluginmanager.rewrite_hook = hook

        if disable_autoload:
            # We don't autoload from distribution package entry points,
            # no need to continue.
            return