Repository: NeurodataWithoutBorders/nwbinspector (language: python)

Issue:
[Add Check]: Missing values should be `None`, not empty string
### What would you like to see added to the NWBInspector?

Sometimes users are missing optional values, such as the NWBFile.experimenter, and they use an empty string as a placeholder instead of just omitting this value by setting it to `None`. `None` is the better approach. We should add this to the best practices and add checks for it.

### Pseudocode or other logic of the check

_No response_

### Do you have any interest in helping implement the check function?

No.

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/NeurodataWithoutBorders/nwbinspector/blob/dev/.github/CODE_OF_CONDUCT.rst)
- [X] Have you ensured this check was not already [requested](https://github.com/neurodatawithoutborders/nwbinspector/issues)?


Discussion / hints:

Fix patch:
diff --git a/nwbinspector/checks/nwb_containers.py b/nwbinspector/checks/nwb_containers.py
index 31f40b695..8999b5573 100644
--- a/nwbinspector/checks/nwb_containers.py
+++ b/nwbinspector/checks/nwb_containers.py
@@ -57,7 +57,7 @@ def check_small_dataset_compression(
             )
 
 
-@ register_check(importance=Importance.BEST_PRACTICE_SUGGESTION, neurodata_type=NWBContainer)
+@register_check(importance=Importance.BEST_PRACTICE_SUGGESTION, neurodata_type=NWBContainer)
 def check_empty_string_for_optional_attribute(nwb_container: NWBContainer):
     """
     Check if any NWBContainer has optional fields that are written as an empty string. These values should just be
@@ -67,11 +67,11 @@ def check_empty_string_for_optional_attribute(nwb_container: NWBContainer):
     ----------
     nwb_container: NWBContainer
     """
-    docval = type(nwb_container).__init__.__docval__["args"]
-    optional_attrs = [_d["name"] for _d in docval if "default" in _d and _d["default"] is None]
+    docval_args = type(nwb_container).__init__.__docval__["args"]
+    optional_attrs = [arg["name"] for arg in docval_args if "default" in arg and arg["default"] is None]
     fields = [attr for attr in optional_attrs if getattr(nwb_container, attr) == ""]
     for field in fields:
         yield InspectorMessage(
             message=f'The attribute "{field}" is optional and you have supplied an empty string. Improve my omitting '
-                    f'this attribute (in MatNWB or PyNWB) or entering as None (in PyNWB)'
+            "this attribute (in MatNWB or PyNWB) or entering as None (in PyNWB)"
         )


Test patch:
diff --git a/tests/unit_tests/test_containers.py b/tests/unit_tests/test_containers.py
index 01166c441..4a89fa731 100644
--- a/tests/unit_tests/test_containers.py
+++ b/tests/unit_tests/test_containers.py
@@ -2,14 +2,19 @@
 from tempfile import mkdtemp
 from shutil import rmtree
 from unittest import TestCase
-from datetime import  datetime
+from datetime import datetime
 
 import h5py
 import numpy as np
 from pynwb import NWBContainer, NWBFile
 
-from nwbinspector import InspectorMessage, Importance, check_small_dataset_compression, \
-    check_large_dataset_compression, check_empty_string_for_optional_attribute
+from nwbinspector import (
+    InspectorMessage,
+    Importance,
+    check_small_dataset_compression,
+    check_large_dataset_compression,
+    check_empty_string_for_optional_attribute,
+)
 from nwbinspector.register_checks import Severity
 
 
@@ -93,16 +98,15 @@ def test_hit_check_empty_string_for_optional_attribute():
 
     assert check_empty_string_for_optional_attribute(nwb)[0] == InspectorMessage(
         message='The attribute "pharmacology" is optional and you have supplied an empty string. Improve my omitting '
-                'this attribute (in MatNWB or PyNWB) or entering as None (in PyNWB)',
+        "this attribute (in MatNWB or PyNWB) or entering as None (in PyNWB)",
         importance=Importance.BEST_PRACTICE_SUGGESTION,
         location="/",
         object_type="NWBFile",
         object_name="root",
-        check_function_name='check_empty_string_for_optional_attribute',
+        check_function_name="check_empty_string_for_optional_attribute",
     )
 
 
 def test_miss_check_empty_string_for_optional_attribute():
     nwb = NWBFile("aa", "aa", datetime.now())
-
-    assert check_empty_string_for_optional_attribute(nwb) == None
\ No newline at end of file
+    assert check_empty_string_for_optional_attribute(nwb) is None