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

Add typehints for step func returning types

Open starod00m opened this issue 1 year ago • 1 comments

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

starod00m avatar Sep 20 '24 04:09 starod00m

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 20 '24 04:09 CLAassistant