allure-framework / allure-python

Allure integrations for Python test frameworks
https://allurereport.org/
Apache License 2.0
718 stars 237 forks source link

Add type annotation especially for function applied as a decorators #719

Closed gryznar closed 1 year ago

gryznar commented 1 year ago

I'm submitting a ...

What is the current behavior?

Functions and methods who belongs to allure public API do not have type annotations. This is a problem especially with theses which are applied as a decorator (e.g. allure.title) . For IDE this is not obvious to infer type and usualy params are threated like a params of inner function which in most cases are *args, **kwargs.

What is the expected behavior?

Type hints for params of a decorated funtion via allure.sth (e.g. step) are the same as for undecorated one. It is easily doable via ParamSpec.

What is the motivation / use case for changing the behavior?

Support systems for type hints, improve user experience.

Please tell us about your environment:

delatrie commented 1 year ago

Hi, @gryznar !

Type annotations for the public API are in the list of things to do in the near future. I will notify you here on any updates, stay tuned!

gryznar commented 1 year ago

Thank you so much!

pt., 9 gru 2022, 20:00 użytkownik Maxim @.***> napisał:

Hi, @gryznar https://github.com/gryznar !

Type annotations for the public API are in the list of things to do in the near future. I will notify you here on any updates, stay tuned!

— Reply to this email directly, view it on GitHub https://github.com/allure-framework/allure-python/issues/719#issuecomment-1344658575, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVR4OCCO667M4PUJFLI6FGDWMN6VJANCNFSM6AAAAAASZPFX5E . You are receiving this because you were mentioned.Message ID: @.***>

skhomuti commented 1 year ago

Hey @gryznar! Could you please provide code example that has no type hints? And what IDE do you use?

gryznar commented 1 year ago

Strange, because currently it is working well on PyCharm 2022.3. The case looked like this:

import allure

class BaseClass:
    @allure.step("some step")
    def func(self, arg1: str):
        pass

class ChildClass(BaseClass):
    def func(self, arg1: str):
        super().func(arg1)  # *args, **kwargs here

As I've dived deeper, annotations are proper: image