PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: stephencelis/SQLite.swift (swift)
Issue: Is there a “VACUUM” function to reduce file size?
I delete a lot of data when adding new one to my database to keep the file size low. But as the deleted rows remain in the memory the file size doesn’t reduce. Is there a supported vacuum function?
Pull request description: Fixes #1047 

Usage:
```swift
try connection.vacuum()
```

Patch:
diff --git a/Sources/SQLite/Core/Connection.swift b/Sources/SQLite/Core/Connection.swift
index f4a9e8cb..8fd07cc1 100644
--- a/Sources/SQLite/Core/Connection.swift
+++ b/Sources/SQLite/Core/Connection.swift
@@ -252,6 +252,17 @@ public final class Connection {
     @discardableResult public func run(_ statement: String, _ bindings: [String: Binding?]) throws -> Statement {
         return try prepare(statement).run(bindings)
     }
+    
+    // MARK: - VACUUM
+    
+    /// Run a vacuum on the database
+    ///
+    /// - Throws: `Result.Error` if query execution fails.
+    ///
+    /// - Returns: The statement.
+    @discardableResult public func vacuum() throws -> Statement {
+        return try run("VACUUM")
+    }
 
     // MARK: - Scalar
 


Test patch:
diff --git a/Tests/SQLiteTests/ConnectionTests.swift b/Tests/SQLiteTests/ConnectionTests.swift
index fdfc9637..a05cceb5 100644
--- a/Tests/SQLiteTests/ConnectionTests.swift
+++ b/Tests/SQLiteTests/ConnectionTests.swift
@@ -111,6 +111,10 @@ class ConnectionTests : SQLiteTestCase {
         try! db.run("SELECT * FROM users WHERE admin = $admin", ["$admin": 0])
         AssertSQL("SELECT * FROM users WHERE admin = 0", 4)
     }
+    
+    func test_vacuum() {
+        try! db.vacuum()
+    }
 
     func test_scalar_preparesRunsAndReturnsScalarValues() {
         XCTAssertEqual(0, try! db.scalar("SELECT count(*) FROM users WHERE admin = 0") as? Int64)
Repository: platers/obsidian-linter (ts)
Issue: Colon in H1 invalidates YAML
I used some titles with colons (e.g., `#V02: A title`). 
The automatic insert in the yaml title as `title: V02: A title` results in an invalid yaml (reason: double colon).

Suggestion: Some characters may be filtered before inserting them in the yaml.

Edit: On a second thought, the titles could just be inserted in quotation marks. ;)
Pull request description: Escape title to be valid YAML
Fixes #185

Patch:
diff --git a/src/rules.ts b/src/rules.ts
index 4eeda54..bdb1733 100644
--- a/src/rules.ts
+++ b/src/rules.ts
@@ -10,6 +10,7 @@ import {
   loadYAML,
   moveFootnotesToEnd,
   yamlRegex,
+  escapeYamlString,
 } from './utils';
 import {
   Option,
@@ -921,6 +922,8 @@ export const rules: Rule[] = [
         });
         title = title || options['metadata: file name'];
 
+        title = escapeYamlString(title);
+
         return formatYAML(text, (text) => {
           const title_match_str = `\n${options['Title Key']}.*\n`;
           const title_match = new RegExp(title_match_str);
diff --git a/src/utils.ts b/src/utils.ts
index b900c60..a04a486 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,7 +1,7 @@
 import {remark} from 'remark';
 import {visit} from 'unist-util-visit';
 import type {Position} from 'unist';
-import {load} from 'js-yaml';
+import {load, dump} from 'js-yaml';
 import remarkGfm from 'remark-gfm';
 
 // Useful regexes
@@ -192,3 +192,7 @@ export function loadYAML(yaml_text: string): any {
   }
   return parsed_yaml;
 }
+
+export function escapeYamlString(str: string): string {
+  return dump(str).slice(0, -1);
+}


Test patch:
diff --git a/src/test.ts b/src/test.ts
index c9b00cb..d6e8994 100644
--- a/src/test.ts
+++ b/src/test.ts
@@ -597,3 +597,65 @@ describe('Disabled rules parsing', () => {
     expect(getDisabledRules(text)).toEqual([]);
   });
 });
+
+describe('YAML Title', () => {
+  it('Keeps unescaped title if possible', () => {
+    const before = dedent`
+    # Hello world
+    `;
+
+    const after = dedent`
+    ---
+    title: Hello world
+    ---
+    # Hello world
+    `;
+
+    expect(rulesDict['yaml-title'].apply(before, {'Title Key': 'title'})).toBe(after);
+  });
+
+  it('Escapes title if it contains colon', () => {
+    const before = dedent`
+    # Hello: world
+    `;
+
+    const after = dedent`
+    ---
+    title: 'Hello: world'
+    ---
+    # Hello: world
+    `;
+
+    expect(rulesDict['yaml-title'].apply(before, {'Title Key': 'title'})).toBe(after);
+  });
+
+  it('Escapes title if it starts with single quote', () => {
+    const before = dedent`
+    # 'Hello world
+    `;
+
+    const after = dedent`
+    ---
+    title: '''Hello world'
+    ---
+    # 'Hello world
+    `;
+
+    expect(rulesDict['yaml-title'].apply(before, {'Title Key': 'title'})).toBe(after);
+  });
+
+  it('Escapes title if it starts with double quote', () => {
+    const before = dedent`
+    # "Hello world
+    `;
+
+    const after = dedent`
+    ---
+    title: '"Hello world'
+    ---
+    # "Hello world
+    `;
+
+    expect(rulesDict['yaml-title'].apply(before, {'Title Key': 'title'})).toBe(after);
+  });
+});
Repository: zeit/swr (ts)
Issue: When using SSR and initialData, is it possible to prevent first validation after render?
In `getInitialProps()` I call my fetcher function which queries the db for data. I pass that initial data to `useSWR` as `initialData` option. However, as soon as it renders, it queries the server again with the same end point (returning the same data set). I would expect that it would not query on render if `initialData` is passed, or there would be an option to prevent this.

I would like to prevent the server getting hit twice in a short timeframe with the same endpoint.
Pull request description: skip immediate revalidation when initalData is provided
This fixes #194.

I wasn't sure if this should be set via another option or not but if so let me know and I can update.


Patch:
diff --git a/src/use-swr.ts b/src/use-swr.ts
index 9c9e510..d6d21fb 100644
--- a/src/use-swr.ts
+++ b/src/use-swr.ts
@@ -382,16 +382,18 @@ function useSWR<Data = any, Error = any>(
     const softRevalidate = () => revalidate({ dedupe: true })
 
     // trigger a revalidation
-    if (
-      typeof latestKeyedData !== 'undefined' &&
-      !IS_SERVER &&
-      window['requestIdleCallback']
-    ) {
-      // delay revalidate if there's cache
-      // to not block the rendering
-      window['requestIdleCallback'](softRevalidate)
-    } else {
-      softRevalidate()
+    if (!config.initialData) {
+      if (
+        typeof latestKeyedData !== 'undefined' &&
+        !IS_SERVER &&
+        window['requestIdleCallback']
+      ) {
+        // delay revalidate if there's cache
+        // to not block the rendering
+        window['requestIdleCallback'](softRevalidate)
+      } else {
+        softRevalidate()
+      }
     }
 
     // whenever the window gets focused, revalidate


Test patch:
diff --git a/test/use-swr.test.tsx b/test/use-swr.test.tsx
index 64b964d..bdb7cbd 100644
--- a/test/use-swr.test.tsx
+++ b/test/use-swr.test.tsx
@@ -243,8 +243,10 @@ describe('useSWR', () => {
   })
 
   it('should accept initial data', async () => {
+    const fetcher = jest.fn(() => 'SWR')
+
     function Page() {
-      const { data } = useSWR('initial-data-1', () => 'SWR', {
+      const { data } = useSWR('initial-data-1', fetcher, {
         initialData: 'Initial'
       })
       return <div>hello, {data}</div>
@@ -252,13 +254,10 @@ describe('useSWR', () => {
 
     const { container } = render(<Page />)
 
+    expect(fetcher).not.toBeCalled()
     expect(container.firstChild.textContent).toMatchInlineSnapshot(
       `"hello, Initial"`
     )
-    await waitForDomChange({ container }) // mount
-    expect(container.firstChild.textContent).toMatchInlineSnapshot(
-      `"hello, SWR"`
-    )
   })
 
   it('should set config as second parameter', async () => {
Repository: MartinThoma/flake8-simplify (python)
Issue: SIM104 proposes yield from under async generators
## Desired change

* **Rule(s)**: SIM104
* **Adjustment**: do not propose `yield from` on async generators.

## Explanation

Yield-from is strictly forbidden under async generators, it looks like flake8-simplify does not check if generator is async before proposing that change.

## Example

```python
async def items():
    for c in 'abc':
        yield c
```

Pull request description: SIM104: yield from is not possible for async functions
Closes #67

Patch:
diff --git a/flake8_simplify.py b/flake8_simplify.py
index c6487f3..c2da734 100644
--- a/flake8_simplify.py
+++ b/flake8_simplify.py
@@ -311,6 +311,8 @@ def _get_sim104(node: ast.For) -> List[Tuple[int, int, str]]:
         or node.orelse != []
     ):
         return errors
+    if isinstance(node.parent, ast.AsyncFunctionDef):  # type: ignore
+        return errors
     iterable = to_source(node.iter)
     errors.append(
         (node.lineno, node.col_offset, SIM104.format(iterable=iterable))


Test patch:
diff --git a/tests/test_simplify.py b/tests/test_simplify.py
index bc23a17..b429d04 100644
--- a/tests/test_simplify.py
+++ b/tests/test_simplify.py
@@ -153,6 +153,16 @@ def test_sim104():
     assert ret == {"1:0 SIM104 Use 'yield from iterable'"}
 
 
+def test_s104_async_generator_false_positive():
+    ret = _results(
+        """async def items():
+    for c in 'abc':
+        yield c"""
+    )
+    for el in ret:
+        assert "SIM104" not in el
+
+
 def test_sim105():
     ret = _results(
         """try: