Closed pylint-bot closed 8 years ago
Originally reported by: Pedro Rodriguez (BitBucket: pedrorodriguez, GitHub: @pedrorodriguez?)
I have the following code that is being run through pylint:
class LazyFile(object): # pylint: disable=too-few-public-methods,too-many-instance-attributes def __init__(self, path, delimiter=None, mode='r', buffering=-1, encoding=None, errors=None, newline=None): # pylint: disable=too-many-arguments self.path = path self.delimiter = delimiter self.mode = mode self.buffering = buffering self.encoding = encoding self.errors = errors self.newline = newline self.file = None def __iter__(self): if self.file is not None: self.file.close() self.file = builtins.open(self.path, mode=self.mode, buffering=self.buffering, encoding=self.encoding, errors=self.errors, newline=self.newline) return self.file
And gives this error: E: 72, 4: __iter__ returns non-iterator (non-iterator-returned)
E: 72, 4: __iter__ returns non-iterator (non-iterator-returned)
This seems wrong given that a file is its own iterator (that is, iter(file)=file.
iter(file)=file
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):
Thank you for the report.
Original comment by BitBucket: dmand, GitHub: @dmand?:
Should be fixed by df18ac7d2dca.
Originally reported by: Pedro Rodriguez (BitBucket: pedrorodriguez, GitHub: @pedrorodriguez?)
I have the following code that is being run through pylint:
And gives this error:
E: 72, 4: __iter__ returns non-iterator (non-iterator-returned)
This seems wrong given that a file is its own iterator (that is,
iter(file)=file
.