nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: matchms/matchms
Pull request #741 (2025-03-11 10:56:54)

allows users to save mgf files in write mode as well as well as append mode
## Describe your changes
Added functionality that allows users to add a file_mode when writing .mgf files.

## Issue ticket number and link
https://github.com/matchms/matchms/issues/726

## Checklist before requesting a review
- [x] I have performed a self-review of my code
- [x] I have added thorough tests to see if it is a core feature.



Patch:
diff --git a/matchms/exporting/save_as_mgf.py b/matchms/exporting/save_as_mgf.py
index c2efec29..226219d0 100644
--- a/matchms/exporting/save_as_mgf.py
+++ b/matchms/exporting/save_as_mgf.py
@@ -12,11 +12,11 @@ logger = logging.getLogger("matchms")
 
 
 @rename_deprecated_params(param_mapping={"spectrums": "spectra"}, version="0.26.5")
-def save_as_mgf(
-    spectra: Union[List[Spectrum], Spectrum],
-    filename: str,
-    export_style: str = "matchms",
-):
+def save_as_mgf(spectra: Union[List[Spectrum], Spectrum],
+                filename: str,
+                export_style: str = "matchms",
+                file_mode: str = "a",
+                ) -> None:
     """Save spectrum(s) as mgf file.
 
     Example:
@@ -46,6 +46,9 @@ def save_as_mgf(
     export_style:
         Converts the keys to the required export style. One of ["matchms", "massbank", "nist", "riken", "gnps"].
         Default is "matchms"
+    file_mode: str
+        This is an optional parameter which defines the mode the file will be opened in.  
+        Default is "a" (append). The other option is "w" (write). If set worngly it will default to "a".
     """
     if not isinstance(spectra, list):
         # Assume that input was a single Spectrum.
@@ -65,7 +68,6 @@ def save_as_mgf(
             if "fingerprint" in spectrum_dict["params"]:
                 del spectrum_dict["params"]["fingerprint"]
             yield spectrum_dict
-
-    py_mgf.write(
-        spectrum_dict_generator(spectra), filename, file_mode="a", encoding="utf-8"
-    )
+    if file_mode not in ["a", "w"]:
+        file_mode = "a"
+    py_mgf.write(spectrum_dict_generator(spectra), filename, file_mode=file_mode, encoding="utf-8")
\ No newline at end of file


Test patch:
diff --git a/tests/exporting/test_save_as_mgf.py b/tests/exporting/test_save_as_mgf.py
index 7c3c4ee1..ad0433a2 100644
--- a/tests/exporting/test_save_as_mgf.py
+++ b/tests/exporting/test_save_as_mgf.py
@@ -28,10 +28,13 @@ def test_save_as_mgf_single_spectrum():
     # Write to test file
     with tempfile.TemporaryDirectory() as d:
         filename = os.path.join(d, "test.mgf")
+        filename2 = os.path.join(d, "test2.mgf")
         save_as_mgf(spectrum, filename)
+        save_as_mgf(spectrum, filename2, file_mode="w")
 
         # test if file exists
         assert os.path.isfile(filename)
+        assert os.path.isfile(filename2)
 
         # Test if content of mgf file is correct
         with open(filename, "r", encoding="utf-8") as f:
Repository: line/line-bot-sdk-nodejs
Pull request #417 (2023-01-13 01:14:57)

fix: issue#416, change verifyIdToken base prefix 


Patch:
diff --git a/lib/client.ts b/lib/client.ts
index c888aa2..3b49e45 100644
--- a/lib/client.ts
+++ b/lib/client.ts
@@ -758,7 +758,7 @@ export class OAuth {
     nonce?: string,
     user_id?: string,
   ): Promise<Types.VerifyIDToken> {
-    return this.http.postForm(`${OAUTH_BASE_PREFIX}/verify`, {
+    return this.http.postForm(`${OAUTH_BASE_PREFIX_V2_1}/verify`, {
       id_token,
       client_id,
       nonce,


Test patch:
diff --git a/test/client.spec.ts b/test/client.spec.ts
index 580c6cd..6f60afa 100644
--- a/test/client.spec.ts
+++ b/test/client.spec.ts
@@ -1120,7 +1120,7 @@ describe("oauth", () => {
     const client_id = "test_client_id";
     const nonce = "test_nonce";
     const user_id = "test_user_id";
-    const scope = nock(OAUTH_BASE_PREFIX, interceptionOption)
+    const scope = nock(OAUTH_BASE_PREFIX_V2_1, interceptionOption)
       .post("/verify", {
         id_token,
         client_id,