-
Notifications
You must be signed in to change notification settings - Fork 12
DeviceManager adds device doc string to factory method #1829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
I was literally just thinking of doing this |
Saved you the work 😄 |
dan-fernandes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good once the failing tests are sorted
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1829 +/- ##
==========================================
- Coverage 99.06% 99.05% -0.01%
==========================================
Files 290 290
Lines 11092 11107 +15
==========================================
+ Hits 10988 11002 +14
- Misses 104 105 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…com/DiamondLightSource/dodal into device_manager_adds_device_doc_string
tests/test_device_manager.py
Outdated
|
|
||
| assert OphydV2Device.__doc__ is not None | ||
| assert ( | ||
| foo.__doc__ == f"{OphydV2Device.__name__}:\n\n{cleandoc(OphydV2Device.__doc__)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(here and below)
Replicating the implementation using f-strings here doesn't really test anything. It would be better if the expected values were normal literals.
To avoid depending on the docs of Device, it might be useful to have a DocsDevice to go with the NoDocsDevice with docs that won't change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reused the _type_docs function in the tests which I think makes it much cleaner now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still defeats the point of the test though. They're now effectively assert make_docs(func) == make_docs(func)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, it still checks to make sure the formatting of the docs is still called through this function.
Would me adding another test specifically for _type_docs works as expected be suitable enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would help, but raises the question of whether private functions should be tested directly or only via the things that call them. I still think it would be useful for the tests to include an example of what the full docs should look like but I'll leave it up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the additional tests. I personally think it is sufficient but let me know what you think
Co-authored-by: Peter Holloway <peter.holloway@diamond.ac.uk>
Co-authored-by: Peter Holloway <peter.holloway@diamond.ac.uk>
| return _type_docs(return_type) | ||
|
|
||
|
|
||
| def _type_docs(target: type[V1 | V2], extra_docs: str = "") -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By making this take extra_docs the type_docs name is no longer correct and it re-introduces another string comparison. Is there a benefit to moving the concatenation out of the format method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it makes the function much more reusable with the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the other comment about testing private functions.
…com/DiamondLightSource/dodal into device_manager_adds_device_doc_string
Fixes #780
Examples
Device without documentation
Device with documentation
Device with factory documentation and device documentation
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}