Skip to content
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

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

Open
1 of 3 tasks
vbotay opened this issue Sep 17, 2024 · 0 comments
Open
1 of 3 tasks

Comments

@vbotay
Copy link

vbotay commented Sep 17, 2024

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

Other information

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

No branches or pull requests

1 participant