python-decopatch icon indicating copy to clipboard operation
python-decopatch copied to clipboard

Add type hints, to account for different call variants

Open last-partizan opened this issue 3 years ago • 3 comments

I'm using pytest-cases, and using @fixture without parenthesis, and it produces errors in pyright.

@fixture
def some_fixture():
    ...
Argument of type "() -> str" cannot be assigned to parameter "scope" of type "str" in function "fixture"

There is @overload in typing to handle such cases https://mypy.readthedocs.io/en/stable/generics.html#decorator-factories

Are you interested in adding support for type hinting?

Progress:

  • [x] #23
  • [x] #27
  • [x] #30
  • [ ] Typing for class_decorator and decorator

last-partizan avatar Jan 29 '22 13:01 last-partizan

Thanks @last-partizan ! Sure, that would be a good addition ! Would you like to have a try ?

smarie avatar Feb 01 '22 15:02 smarie

Yes, i'll try to do it!

last-partizan avatar Feb 02 '22 07:02 last-partizan

https://github.com/smarie/python-decopatch/pull/23

Please, take a look :)

last-partizan avatar Feb 05 '22 13:02 last-partizan