'PyCharm type-hinting not working properly with stacked pytest parametrize decorators

Consider the following example:

base_case.py

import pytest


@pytest.mark.parametrize('hello')
@pytest.mark.parametrize('hi')
class BaseCase:
    @property
    def my_list(self) -> list:  # my_list should pop up on hints in a test class
        return [1, 2, 3]

test_01_example.py

from base_case import BaseCase

class Test01Hello(BaseCase):
    def test_01_hi(self):
        self.  # press ctrl + space for hints

PyCharm fails to hint any attributes from BaseCase class. If I press ctrl + space on self. then the following hints from MarkDecorator class appear, no trace of BaseCase:

hint annotations with stacked decorators

By commenting one of the decorators, PyCharm is able to resolve the hints and everything works properly:

hint annotations with single decorator

I've tried creating python stub files, following this artice but without much success.

How can I instruct PyCharm that multiple parametrize decorators should return a decorated class and it would hint the attributes of BaseClass inside test class?


UPDATE

Implementing BaseCase in such way, makes hints to be properly resolved inside a class test but looks really wanky:

import pytest


mark1 = pytest.mark.parametrize('hello')
mark2 = pytest.mark.parametrize('hi')
@mark1
@mark2
class BaseCase:
    @property
    def my_list(self) -> list:  # my_list should pop up on hints in a test class
        return [1, 2, 3]

I'm still looking for a proper solution



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source