sighalt / logdecorator

Move logging code out of your business logic with python decorators.
MIT License
74 stars 12 forks source link

Decorators hide actual type hints #21

Open gargaroff opened 1 year ago

gargaroff commented 1 year ago

Hi! First of all, thanks for the great project. I've been using it since recently and find it a great convenience.

Unfortunately I noticed that the decorators hide the type hints of the decorated functions, making mypy complain about mismatching types. For example:

@log_on_end(...)
def foo() -> bool:
  return True

Results in mypy reporting the returned type as Any, while the actual type is bool. This can be solved by using PEP-612.

Is there any chance you could update your type hints to use PEP-612 for the next release in order to preserve the original types?

sighalt commented 1 year ago

Hi, thank you for reporting and your kind words.

I already implemented this ~90%, but I still struggle to get mypy not complaining about the annotation of the async implementation of logdecorator. I'll keep trying though, and will update you here.

gargaroff commented 1 year ago

Thanks for the effort!