parameters-validation icon indicating copy to clipboard operation
parameters-validation copied to clipboard

Sphynx Documentation deep parsing

Open SebastienAndreo opened this issue 4 years ago • 1 comments
trafficstars

Dear Rodrigo,

First of all thanks for that really nice package! This post is not a bug or a feature request, I am looking for advice, I am using the parameter_validation package in combination with a Sphynx and RST file documentation generator, and I am facing the following issue the sphynx generator analyzes the complete call stack and I obtain for instance such a thing:

delete_file(file: parameters_validation.parameter_validation_decorator.parameter_validation..func_partial..validation_partial)

Do you have any guidance or tip to avoid it?

thanks in advance

SebastienAndreo avatar Nov 27 '20 14:11 SebastienAndreo

Hi @SebastienAndreo, thank you for using the package and bringing feedback! :hearts:

AFAIK, there is no way on your end to avoid that, though there may be some ways the library can circumvent this issue depending on how Sphinx inspects a method's signature. I've been experimenting with signature patching for another lib which I maintain, I'll see if I can port this to parameters-validation too but for the time being, I can't think of an easy workaround.

If this issue is impeditive for you I would suggest either do validations manually while I don't fix this or declaring the actual function without the validation hints and decorator and later overwriting it like this:

# .../module/foo.py
def foo(a: int, b: str):
    ...

# .../module/__init__.py
from parameters_validation import no_whitespaces, non_negative, validate_parameters
from functools import wraps

from .foo import foo as raw_foo


@wraps(raw_foo)
@validate_parameters
def foo(a: non_negative(int), b: no_whitespaces(str)):
    return raw_foo(a, b)

__all__ = [
    "foo",
]

I do realize this may be impractical but as I said I can't think of any easy workarounds until I fix the package.

At last: though I would like to look into this soon, actually I don't have the time to do this right now. So just letting you know that we're talking about 1 to 2 months until I release a fix. Of course, you or anyone willing to fix this sooner may submit a PR, which I'd look at promptly.

Again, thank you for your time bringing this to attention and for using the package! I'll keep you posted on any updates in this issue.

roo-oliv avatar Nov 29 '20 20:11 roo-oliv