Closed Risitop closed 1 month ago
Thanks for posting this. Do you get an error?
It might be that the numpy parser attempts to parse the whole int, optional
as a type, but instead it should account for this exception.
So as a minimum it should verify the type (int), but I guess it would be cool if it also spotted misplaced ", optional"? Not sure if possible though - I will have a look!
Hi Jeppe, thanks a lot for this fast answer. I will try to replicate the issue on a minimal example, as it seems to be a little bit more complicated than what I first thought to make a simple failing case.
Edit: ok, so the aforementioned example indeed seems to trigger the following error
/test.py::f FAIL | Unable to parse docstring:
Corresponding config file:
{
"fail_on_missing_docstring": true,
"fail_on_raises_section": false,
"parser": "numpy",
"exclude_methods": ["_*"],
"exclude_functions": ["_*"],
"verbosity": 1
}
I think a possible simple fix would indeed be to add a handler for a possible ", optional"
suffix, so that the numpy parser does not try to parse it as part of the parameter type. :)
And yes, as you suggested it could even go one step further and check that every , optional
argument indeed has a set default value in the function definition.
I've created a PR here: https://github.com/jepperaskdk/pydoctest/pull/51
There's a problem with the code-coverage tool - I will try to resolve it.
I've disabled codecov since it seems to be broken. I've released pydoctest 0.2.0 which should support optional - can you verify that it solves your problem? :)
Yes, works well, thanks! 🙏
Great, thanks for finding this. I'll close this then - let me know if you find something else. 😁
Hi, thank you very much for developing this great tool.
One question though, it seems like pydoctest is right now unable to parse optional arguments:
This
, optional
keyword being standard in numpy, would you have any tip to avoid this issue and allowing the package to parse functions with optional parameters? Thanks!