Q:

Incorrect call arguments for __new__ in PyCharm

class IntTuple(tuple):
    def __new__(cls, iterable):
        generator = (x for x in iterable if isinstance(x, int) and x > 0)
        return super().__new__(cls, generator)

Pycharm suggests me to remove the generator which is in the return. Why?
It said: This inspection reports discrepancies between declared parameters and actual arguments, as well as incorrect arguments (e.g. duplicate named arguments) and incorrect argument order. Decorators are analyzed, too.
But its output was what I expected.
Example:
t = IntTuple([1, -1, "abc", 2, [1, 2], 3])

print(t)

output: (1, 2, 3)

I'm new to Python, so I think this may lack of standardization.
How should I improve it?

A:

This is not specific to tuple, calling most builtin type's special method leads PyCharm to get confused with type signatures.
str.__new__(str, 'foo') # This will confuse PyCharm even though it is correct

PyCharm resolves tuple.__new__ as being inherited from builtins.object.__new__. This is not the real method used to create a tuple, but it fails to find the correct one (which is not in a .py file since it is written in C).

This is most likely a bug and, unfortunately, this is not something you can fix through settings, except by disabling Incorrect call arguments inspection which I do not recommend.
The bottom line is that PyCharm inspection sometimes gives false positives due to having to inspect a dynamically typed language. This is not a surprise and you will sometimes have to ignore inspection errors it raises.
A word on your code
On another note, I want to point out that you might want to cover the case where you create an empty IntTuple in the same way it can be done with tuple.
tuple() # ()

For this you could have a default iterable.
class IntTuple(tuple):
    def __new__(cls, iterable=()):
        generator = (x for x in iterable if isinstance(x, int) and x > 0)
        return super().__new__(cls, generator)

IntTuple() # ()

