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?