Repository: internetarchive/openlibrary

Issue:
Fix YAML Load Warnings in three files
<!-- What problem are we solving? What does the experience look like today? What are the symptoms? -->

Current versions of [PyYAML](https://github.com/yaml/pyyaml) want to see a Loader parameter on calls to `yaml.load()`.  Please modify these files to ensure that pytest does not raise warnings.  Hint: Investigate `safe_load()`.  On the instances in `test_update_work.py`, it would be helpful if the file was closed when we were done reading it.

### Evidence / Screenshot (if possible)

pytest generates these warnings:
```
openlibrary/plugins/admin/tests/test_services.py::test_loader
  /openlibrary/openlibrary/plugins/admin/tests/conftest.py:8: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
    d = yaml.load(f)

openlibrary/tests/solr/test_update_work.py::Test_update_items::test_update_author
  /openlibrary/openlibrary/config.py:21: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
    runtime_config = yaml.load(open(config_file))

openlibrary/tests/solr/test_update_work.py::Test_update_items::test_update_author
  /openlibrary/infogami/__init__.py:168: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
    runtime_config = yaml.load(open(config_file))
```

### Relevant url?
<!-- `https://openlibrary.org/...` -->

### Steps to Reproduce
<!-- What steps caused you to find the bug? -->
1. Go to ...
2. Do ...

<!-- What actually happened after these steps? What did you expect to happen? -->
* Actual: 
* Expected: 

### Details

- **Logged in (Y/N)?** 
- **Browser type/version?** 
- **Operating system?** 
- **Environment (prod/dev/local)?** prod
<!-- If not sure, put prod -->

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->



Discussion:
Hey, can I take up this issue? This would be my first time contributing to OpenLibrary.
Go ahead and submit a PR.

Resolving patch:
diff --git a/openlibrary/config.py b/openlibrary/config.py
--- a/openlibrary/config.py
+++ b/openlibrary/config.py
@@ -18,7 +18,8 @@ def load(config_file):
     """
     # for historic reasons
     global runtime_config
-    runtime_config = yaml.load(open(config_file))
+    with open(config_file) as in_file:
+        runtime_config = yaml.safe_load(in_file)
 
 
 def load_config(config_file):
@@ -33,12 +34,13 @@ def load_config(config_file):
     server.update_config(config.infobase)
 
 def setup_infobase_config(config_file):
-    """Reads the infoabse config file and assign it to config.infobase.
+    """Reads the infobase config file and assign it to config.infobase.
     The config_file is used as base to resolve relative path, if specified in the config.
     """
     if config.get("infobase_config_file"):
         dir = os.path.dirname(config_file)
         path = os.path.join(dir, config.infobase_config_file)
-        config.infobase = yaml.safe_load(open(path).read())
+        with open(path) as in_file:
+            config.infobase = yaml.safe_load(in_file)
     else:
         config.infobase = {}


Test patch:
diff --git a/openlibrary/plugins/admin/tests/conftest.py b/openlibrary/plugins/admin/tests/conftest.py
--- a/openlibrary/plugins/admin/tests/conftest.py
+++ b/openlibrary/plugins/admin/tests/conftest.py
@@ -4,7 +4,5 @@ def serviceconfig(request):
     import os
     import yaml
     root = os.path.dirname(__file__)
-    f = open(os.path.join(root, "sample_services.yml"))
-    d = yaml.load(f)
-    f.close()
-    return d
+    with open(os.path.join(root, "sample_services.yml")) as in_file:
+        return yaml.safe_load(in_file)