Fix mock_DeviceModel defaulting manufacturer to None - #2232
Open
HugoFara wants to merge 1 commit into
Open
Conversation
mock_DeviceModel declared `manufacturer: str = None`, but DeviceModel requires `manufacturer` to be a str, so every call raised `TypeError: DeviceModel.__init__: None is not allowed for 'manufacturer'`. The mock has been unusable since it was added in NeurodataWithoutBorders#2088 because no test referenced it. Default `manufacturer` to "manufacturer", matching the style of the other mock defaults, and add mock_DeviceModel to the parametrized mock_functions list so test_mock and test_mock_write cover it.
HugoFara
force-pushed
the
fix-mock-devicemodel-default-manufacturer
branch
from
July 25, 2026 10:41
53b12ec to
b7c3a29
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
mock_DeviceModelhas been unusable since it was introduced in #2088.It declares
manufacturer: str = None, butDeviceModel.__init__requiresmanufacturerto be astr(it is a requireddocvalargument with no default). Every call therefore raises:This went unnoticed because
mock_DeviceModelis referenced by no test — it was never added to themock_functionslist intests/unit/test_mock.pythat drives the parametrizedtest_mockandtest_mock_writetests.pynwb.testing.mockis a public, documented surface used by downstream packages, so the mock being non-functional is a real defect rather than an internal test-only concern.This PR defaults
manufacturerto"manufacturer", matching the existingdescription: str = "description"convention in the same module, and addsmock_DeviceModelto the parametrized list so the behavior is covered going forward.The annotation
manufacturer: stralso becomes truthful, where previously it was annotatedstrbut defaulted toNone.How to test the behavior?
Before this change, on
dev:After this change the call succeeds, and the object round-trips and validates:
The two new parametrizations fail on
devand pass with this change. Confirmed by applying only the test change and reverting the source fix:Results with the full change applied, run locally on Python 3.14, HDMF 6.x:
pytest tests/unitpytest tests/integration/hdf5ruff check .codespellSchema validation ran through the
pynwb.validateAPI, both in the snippet above and inside the integration round-trip suite, which validates every file it writes. Thepython -m pynwb.validateCLI was not invoked separately.Checklist
ruff check . && codespellfrom the source directory.No existing issue covers this; I searched the issue tracker and open PRs for
mock_DeviceModeland found none. Happy to open one first if you would prefer that order.Disclosure: this contribution was prepared with assistance from Claude Opus 5. The defect was found by programmatically constructing every
pynwb.testing.mockobject and writing/validating the result. All commands reported above were executed locally and their output is reproduced as returned.