Repository: qutebrowser/qutebrowser

Issue:
Add info about config.py vs autoconfig.yml to :version
Some more information that could help with triaging support issues in the unusual situation where the supportee provides the output of `:version`.

* Whether a `config.py` was loaded.
* Its [path](https://github.com/qutebrowser/qutebrowser/pull/4286).
* Whether `config.load_autoconfig()` was called.

Related: [Make it clearer that autoconfig.yml isn't getting loaded](https://github.com/qutebrowser/qutebrowser/issues/3504)


Discussion:

Resolving patch:
diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py
--- a/qutebrowser/config/config.py
+++ b/qutebrowser/config/config.py
@@ -285,6 +285,7 @@ def __init__(self,
         self._yaml = yaml_config
         self._init_values()
         self.yaml_loaded = False
+        self.config_py_loaded = False
 
     def _init_values(self) -> None:
         """Populate the self._values dict."""
diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py
--- a/qutebrowser/config/configfiles.py
+++ b/qutebrowser/config/configfiles.py
@@ -644,6 +644,7 @@ def read_config_py(filename: str, raising: bool = False) -> None:
             exception=e, traceback=traceback.format_exc()))
 
     api.finalize()
+    config.instance.config_py_loaded = True
 
     if api.errors:
         raise configexc.ConfigFileErrors('config.py', api.errors)
diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py
--- a/qutebrowser/utils/version.py
+++ b/qutebrowser/utils/version.py
@@ -389,6 +389,13 @@ def _autoconfig_loaded() -> str:
     return "yes" if config.instance.yaml_loaded else "no"
 
 
+def _config_py_loaded() -> str:
+    if config.instance.config_py_loaded:
+        return "{} has been loaded".format(standarddir.config_py())
+    else:
+        return "no config.py was loaded"
+
+
 def version():
     """Return a string with various version information."""
     lines = ["qutebrowser v{}".format(qutebrowser.__version__)]
@@ -454,8 +461,9 @@ def version():
         lines += ['{}: {}'.format(name, path)]
 
     lines += [
-        "",
-        "Autoconfig loaded: {}".format(_autoconfig_loaded()),
+        '',
+        'Autoconfig loaded: {}'.format(_autoconfig_loaded()),
+        'Config.py: {}'.format(_config_py_loaded()),
         'Uptime: {}'.format(_uptime())
     ]
 


Test patch:
diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py
--- a/tests/unit/utils/test_version.py
+++ b/tests/unit/utils/test_version.py
@@ -37,7 +37,8 @@
 import pytest
 
 import qutebrowser
-from qutebrowser.utils import version, usertypes, utils
+from qutebrowser.config import config
+from qutebrowser.utils import version, usertypes, utils, standarddir
 from qutebrowser.misc import pastebin
 from qutebrowser.browser import pdfjs
 
@@ -884,6 +885,7 @@ class VersionParams:
     known_distribution = attr.ib(True)
     ssl_support = attr.ib(True)
     autoconfig_loaded = attr.ib(True)
+    config_py_loaded = attr.ib(True)
 
 
 @pytest.mark.parametrize('params', [
@@ -895,13 +897,16 @@ class VersionParams:
     VersionParams('unknown-dist', known_distribution=False),
     VersionParams('no-ssl', ssl_support=False),
     VersionParams('no-autoconfig-loaded', autoconfig_loaded=False),
+    VersionParams('no-config-py-loaded', config_py_loaded=False),
 ], ids=lambda param: param.name)
-def test_version_output(params, stubs, monkeypatch):
+def test_version_output(params, stubs, monkeypatch, config_stub):
     """Test version.version()."""
     class FakeWebEngineSettings:
         default_user_agent = ('Toaster/4.0.4 Chrome/CHROMIUMVERSION '
                               'Teapot/4.1.8')
 
+    config.instance = config_stub
+    config.instance.config_py_loaded = params.config_py_loaded
     import_path = os.path.abspath('/IMPORTPATH')
     patches = {
         'qutebrowser.__file__': os.path.join(import_path, '__init__.py'),
@@ -940,6 +945,12 @@ class FakeWebEngineSettings:
         'autoconfig_loaded': "yes" if params.autoconfig_loaded else "no",
     }
 
+    if params.config_py_loaded:
+        substitutions["config_py_loaded"] = "{} has been loaded".format(
+            standarddir.config_py())
+    else:
+        substitutions["config_py_loaded"] = "no config.py was loaded"
+
     if params.with_webkit:
         patches['qWebKitVersion'] = lambda: 'WEBKIT VERSION'
         patches['objects.backend'] = usertypes.Backend.QtWebKit
@@ -998,6 +1009,7 @@ class FakeWebEngineSettings:
         PATH DESC: PATH NAME
 
         Autoconfig loaded: {autoconfig_loaded}
+        Config.py: {config_py_loaded}
         Uptime: {uptime}
     """.lstrip('\n'))