nebius/SWE-bench-extra huggingface dataset:
Repository: roaldnefs/salt-lint

Issue:
Check #210 triggers on more than filerights
Currently, check `#210` (in [YamlHasOctalValueRule](https://github.com/roaldnefs/salt-lint/blob/master/lib/saltlint/rules/YamlHasOctalValueRule.py)) has a regex set too wide, and triggers on all numbers starting with a zero.

Proposed solutions:

* Match regex on leading colon + space (`: 0123`)
* Match regex on `mode: 0123`

Comments:

Patch:
diff --git a/lib/saltlint/rules/YamlHasOctalValueRule.py b/lib/saltlint/rules/YamlHasOctalValueRule.py
index 541a9b9..c91b4f8 100644
--- a/lib/saltlint/rules/YamlHasOctalValueRule.py
+++ b/lib/saltlint/rules/YamlHasOctalValueRule.py
@@ -14,7 +14,7 @@ class YamlHasOctalValueRule(SaltLintRule):
     tags = ['formatting']
     version_added = 'v0.0.6'
 
-    bracket_regex = re.compile(r"(?<!['\"])0+[1-9]\d*(?!['\"])")
+    bracket_regex = re.compile(r": (?<!['\"])0+[1-9]\d*(?!['\"])")
 
     def match(self, file, line):
         return self.bracket_regex.search(line)


Test patch:
diff --git a/tests/unit/TestYamlHasOctalValueRule.py b/tests/unit/TestYamlHasOctalValueRule.py
index 996fa63..640aab8 100644
--- a/tests/unit/TestYamlHasOctalValueRule.py
+++ b/tests/unit/TestYamlHasOctalValueRule.py
@@ -16,9 +16,9 @@ testdirectory:
     - file_mode: 700
     - dir_mode: '0775'
 
-testdirectory2:
+testdirectory02:
   file.recurse:
-    - name: /tmp/directory2
+    - name: /tmp/directory02
     - file_mode: 0
     - dir_mode: "0775"
 '''
Repository: robmarkcole/HASS-data-detective

Issue:
db_url_from_hass_config to error out when no recorder section found and DB file doesn't exist
If we can't find a recorder section in `config.db_url_from_hass_config`, we return the SQLite DB. We should only return SQLLite if the file actually exists in the config dir. Else we should error out.

Comments:

Patch:
diff --git a/detective/config.py b/detective/config.py
index 1548e2b..346bff4 100644
--- a/detective/config.py
+++ b/detective/config.py
@@ -51,6 +51,7 @@ def _secret_yaml(loader, node):
 
 def _stub_dict(constructor, node):
     """Stub a constructor with a dictionary."""
+    print("Unsupported YAML found: {} {}".format(node.tag, node.value))
     return {}
 
 
@@ -83,11 +84,18 @@ def load_hass_config(path):
 def db_url_from_hass_config(path):
     """Find the recorder database url from a HASS config dir."""
     config = load_hass_config(path)
-    default = "sqlite:///{}".format(os.path.join(path, "home-assistant_v2.db"))
+    default_path = os.path.join(path, "home-assistant_v2.db")
+    default_url = "sqlite:///{}".format(default_path)
 
     recorder = config.get("recorder")
 
-    if not recorder:
-        return default
+    if recorder:
+        db_url = recorder.get("db_url")
+        if db_url is not None:
+            return db_url
 
-    return recorder.get("db_url", default)
+    if not os.path.isfile(default_path):
+        raise ValueError(
+            "Unable to determine DB url from hass config at {}".format(path))
+
+    return default_url
diff --git a/detective/core.py b/detective/core.py
index 9e2b5be..59fa189 100644
--- a/detective/core.py
+++ b/detective/core.py
@@ -41,6 +41,12 @@ class HassDatabase:
             if fetch_entities:
                 self.fetch_entities()
         except Exception as exc:
+            if isinstance(exc, ImportError):
+                raise RuntimeError(
+                    "The right dependency to connect to your database is "
+                    "missing. Please make sure that it is installed."
+                )
+
             print(exc)
             raise
 


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index 2c64b64..5dd6beb 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -53,7 +53,18 @@ other_secret: test-other-secret
 
 def test_db_url_from_hass_config():
     """Test extracting recorder url from config."""
-    with patch('detective.config.load_hass_config', return_value={}):
+    with patch(
+        'detective.config.load_hass_config', return_value={}
+    ), patch(
+        'os.path.isfile', return_value=False
+    ), pytest.raises(ValueError):
+        config.db_url_from_hass_config('mock-path')
+
+    with patch(
+        'detective.config.load_hass_config', return_value={}
+    ), patch(
+        'os.path.isfile', return_value=True
+    ):
         assert config.db_url_from_hass_config('mock-path') == \
             'sqlite:///mock-path/home-assistant_v2.db'