I have a function named 'sample_func'. As you can see when I call the function without passing the required parameter, there is a red warning.
I have a decorator called 'decorators' in a separate file:
def decorator1(func):
def wrapper(arg1):
print('decorator 1')
return func(arg1)
return wrapper
Now if I decorate the 'sample_func' with the 'decorator1' and call the function without passing the parameter, there is no red warning anymore.
My question is that how can I get this warning? I've seen this: https://stackoverflow.com/a/29569355/3337597 but I'm a little confused. If I determine the acceptable type for the argument and I pass another type, I'll get an 'unexpected type' warning.
I wonder why I'll get the 'unexpected type' warning but won't get the 'parameter unfilled' warning.
I got more confused when I tried this:
When I've defined the 'decorator1' in the same file as 'sample_func', I got the 'parameter unfilled' warning, but I won't when the decorator is defined in another file.
I appreciate any explanation of why this happens.
Also, I appreciate any solution to get the 'parameter unfilled' warning, even if it is using another pattern. I'm developing a package in which most of its functions are decorated to check if the user is logged in (or other conditions) and it would be a bit annoying to use when there is no such warning and you realize you missed a parameter or pass an unexpected parameter only in runtime.