allure-framework / allure-python

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

Add typehints for step func returning types #830

Open starod00m opened 2 months ago

starod00m commented 2 months ago

Context

There are several issues with using pyright as lsp:

  1. When using allure.step as a context manager with with allure.step, pyright returned the errors: Object of type "(...) -> object" cannot be used with "with" because it does not implement __exit__, Object of type "(...) -> object" cannot be used with "with" because it does not implement __enter__ (lsp).
  2. When using allure.step as a decorator along with @property, pyright returned the error: Argument of type "((self: Self@ClassName) -> SomeReturnType) | object" cannot be assigned to parameter "fget" of type "((Any) -> Any) | None" in function "__init__".
  3. The most critical part: because pyright could not correctly determine the types, there was no autocompletion available when writing tests using pyright as the LSP.

Checklist

CLAassistant commented 2 months ago

CLA assistant check
All committers have signed the CLA.