1

I use PyCharm COMMUNITY 2018.2.

I wrote a code as follow.

def increment(func):
    def wrapper(count):
        """
        :param int count:
        """
        count += 1
        func(str(count))
    return wrapper


@increment
def plus_a(count):
    """
    :param str count:
    """
    print(count + "a")


plus_a(1)

Its output is below.

2a

There is no problem. Just as I intended.

But Pycharm inspection detects type error on last row.

Expected type 'str', got 'int' instead

And furthermore, quick documentation doesn't show appropriate information with Ctrl + Q

@increment def plus_a(count: str) -> Optional[Any]

I expect this documentation to tell like "plus_a(count: int)"

Is there any way correcting inspection and getting more appropriate documentation?

4

0 回答 0