comparison mercurial/util.py @ 49572:c4f07a011714

util: implement `writelines()` on atomictempfile With typehints on the vfs objects, pytype will flag this: FAILED: /mnt/c/Users/Matt/hg/.pytype/pyi/mercurial/patch.pyi /usr/bin/python3.8 -m pytype.single --imports_info /mnt/c/Users/Matt/hg/.pytype/imports/mercurial.patch.imports --module-name mercurial.patch -V 3.7 -o /mnt/c/Users/Matt/hg/.pytype/pyi/mercurial/patch.pyi --analyze-annotated --nofail --quick /mnt/c/Users/Matt/hg/mercurial/patch.py File "/mnt/c/Users/Matt/hg/mercurial/patch.py", line 535, in writerej: No attribute 'writelines' on mercurial.util.atomictempfile [attribute-error] In Union[ mercurial.util.atomictempfile, mercurial.vfs.checkambigatclosing, mercurial.vfs.delayclosedfile, mercurial.windows.fdproxy, mercurial.windows.mixedfilemodewrapper ] It's not a real problem there (atomictempfile is only created by passing different args), but it's reasonable for this to implement the function and behave like a normal file. There are other functions missing that can be added if/when needed.
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 04 Nov 2022 17:35:44 -0400
parents d2adebe35635
children 54114bba7c7e
comparison
equal deleted inserted replaced
49571:8fa3f7c3a9ad 49572:c4f07a011714
2540 self._checkambig = checkambig 2540 self._checkambig = checkambig
2541 2541
2542 # delegated methods 2542 # delegated methods
2543 self.read = self._fp.read 2543 self.read = self._fp.read
2544 self.write = self._fp.write 2544 self.write = self._fp.write
2545 self.writelines = self._fp.writelines
2545 self.seek = self._fp.seek 2546 self.seek = self._fp.seek
2546 self.tell = self._fp.tell 2547 self.tell = self._fp.tell
2547 self.fileno = self._fp.fileno 2548 self.fileno = self._fp.fileno
2548 2549
2549 def close(self): 2550 def close(self):