Skip to content

Conversation

@darsor
Copy link

@darsor darsor commented Feb 7, 2025

Context

Current versions of Pyright flag errors on functions decorated with @allure.step, as reported in #828. Adding type hints to allure.step fixes this issue.

Tests pass on Python 3.7 and Python 3.13.

Checklist

@CLAassistant
Copy link

CLAassistant commented Feb 7, 2025

CLA assistant check
All committers have signed the CLA.

@kamikaze
Copy link

kamikaze commented Mar 3, 2025

it seems something is wrong withing CI build pipeline, not the PR. could please someone take a look? this PR might help a lot of people :)

@baev baev force-pushed the allure-step-type-hint branch from f0be248 to 07c7b40 Compare March 26, 2025 13:06
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, @darsor ! Thank you for contributing in allure-python!

Let's better use @typing.overload:

@overload
def step(title: str) -> StepContext:
    ...

@overload
def step(title: _TFunc) -> _TFunc:
    ...

This will require moving StepContext above step.

And it also makes sense to disable type checking when returning the wrapper in StepContext.__call__ for those of us who enable pyright when working on the repo :)

return impl # type: ignore

@delatrie
Copy link
Contributor

Turns out #830 implements this in a more correct way.
I'm closing this PR as a duplicate then.

@delatrie delatrie closed this Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants