Replies: 3 comments 7 replies
-
@okken I hope that the next revision of your book will have fully typed examples. While this makes them bit more verbose, it would make it much easier for people learning to use pytest, to also write them future proof and easy to maintain. |
Beta Was this translation helpful? Give feedback.
4 replies
-
It's been a while now, would it be possible to get an update on this effort? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I'm closing this as solved with the consensus being no types |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
At this moment, only some of pytest documentation uses types and that is not teach test authors to start using them.
Finding the right types to add to test method signatures is not obvious for all users. If we would include already fully types examples across the documentation, it would be much easier to disseminate their use, especially as lots of people start with a copy/paste from documentation.
Once they want to change anything to the copied example, they would be able to benefit from IDE suggestions (auto-complete) when they have types.
Optionally, once we do add missing type, we should also be able to add a check to documentation building that ensures that
mypy --strict
is passing on examples, so regressions would be prevented.Yes, adding types would make the examples more verbose. Still, I do think that this is a small price to pay for getting them more informative and more practical to use. This downside is likely not so bad as adding types would likely also reduce the need for code comments a little bit, due to the extra information being provided by the argument type.
Here is an example about what to expect:
Current example
New example
182 votes ·
Beta Was this translation helpful? Give feedback.
All reactions