Skip to content

Pyright check is failing for functions call decorated with allure step #828

@vbotay

Description

@vbotay

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

Pyright(1.1.380) validation fails for functions calls if they have an allure step decorator.

If the current behaviour is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

Here is a abstract code example that shows an issue

import allure


@allure.step
def get_number_from_str(num: str) -> float:
    return float(num)


def test_add_numbers():
    assert get_number_from_str("2.0") + get_number_from_str("2.5") == 4.5  # noqa: PLR2004

Which leads to a following output:

# pyright .

test_test.py
  test_test.py:10:12 - error: Operator "+" not supported for types "Unknown | object" and "Unknown | object"
    Operator "+" not supported for types "object" and "object" (reportOperatorIssue)
  test_test.py:10:32 - error: Argument of type "Literal['2.0']" cannot be assigned to parameter "func" of type "_TFunc@__call__" in function "__call__"
    Type "Literal['2.0']" is not assignable to type "(...) -> Any"
      Type "Literal['2.0']" is not assignable to type "(...) -> Any" (reportArgumentType)
  test_test.py:10:61 - error: Argument of type "Literal['2.5']" cannot be assigned to parameter "func" of type "_TFunc@__call__" in function "__call__"
    Type "Literal['2.5']" is not assignable to type "(...) -> Any"
      Type "Literal['2.5']" is not assignable to type "(...) -> Any" (reportArgumentType)
3 errors, 0 warnings, 0 informations 

If I delete @allure.step decorator, everything starts working fine.

What is the expected behavior?

Expected behaviour is taht type checking by pyright would pass here

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

Please tell us about your environment:

Python 3.12.3
pyright: 1.1.380

  • Allure version: 2.13.5
  • Test framework: pytest@8.3.3
  • Allure adaptor: allure-pytest@2.13.5

Other information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions