Skip to content

Add typehints for step func returning types #830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

starod00m
Copy link
Contributor

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
Copy link

CLAassistant commented Sep 20, 2024

CLA assistant check
All committers have signed the CLA.

@starod00m starod00m marked this pull request as draft September 20, 2024 05:10
@starod00m starod00m force-pushed the fix-missing-typehints-for-step branch 2 times, most recently from c4a3841 to c13f359 Compare September 20, 2024 05:20
@starod00m starod00m marked this pull request as ready for review September 20, 2024 05:26
@delatrie delatrie force-pushed the fix-missing-typehints-for-step branch from c13f359 to 93c015a Compare March 27, 2025 08:16
@delatrie delatrie linked an issue Mar 27, 2025 that may be closed by this pull request
1 task
Copy link
Contributor

@delatrie delatrie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @starod00m ! Thank you for your contribution!

@delatrie delatrie merged commit d5a7a20 into allure-framework:master Mar 27, 2025
46 checks passed
@delatrie delatrie linked an issue Apr 1, 2025 that may be closed by this pull request
3 tasks
@starod00m starod00m deleted the fix-missing-typehints-for-step branch May 6, 2025 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pyright check is failing for functions call decorated with allure step Need to add overload functions for allure.step()
3 participants