From cb4ba5b38cdcc6e16280704f62253b1c4da58e84 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Mon, 8 Jun 2020 15:39:01 +0200 Subject: [PATCH] Fix linting errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One more green checkmark! ✅ --- tests/storage/test_filesystem.py | 4 ++-- tests/storage/test_http_with_singlefile.py | 2 +- vdirsyncer/cli/utils.py | 4 ++-- vdirsyncer/storage/etesync.py | 4 ++-- vdirsyncer/storage/filesystem.py | 4 ++-- vdirsyncer/storage/google.py | 2 +- vdirsyncer/storage/singlefile.py | 2 +- vdirsyncer/utils.py | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/storage/test_filesystem.py b/tests/storage/test_filesystem.py index 3dcd5ff..39a4880 100644 --- a/tests/storage/test_filesystem.py +++ b/tests/storage/test_filesystem.py @@ -24,7 +24,7 @@ class TestFilesystemStorage(StorageTests): return inner def test_is_not_directory(self, tmpdir): - with pytest.raises(IOError): + with pytest.raises(OSError): f = tmpdir.join('hue') f.write('stub') self.storage_class(str(tmpdir) + '/hue', '.txt') @@ -55,7 +55,7 @@ class TestFilesystemStorage(StorageTests): def test_post_hook_inactive(self, tmpdir, monkeypatch): def check_call_mock(*args, **kwargs): - assert False + raise AssertionError() monkeypatch.setattr(subprocess, 'call', check_call_mock) diff --git a/tests/storage/test_http_with_singlefile.py b/tests/storage/test_http_with_singlefile.py index 9f86ebd..48c4587 100644 --- a/tests/storage/test_http_with_singlefile.py +++ b/tests/storage/test_http_with_singlefile.py @@ -63,7 +63,7 @@ class TestHttpStorage(StorageTests): try: with open(self.tmpfile, 'rb') as f: r._content = f.read() - except IOError: + except OSError: r._content = b'' r.headers['Content-Type'] = 'text/calendar' diff --git a/vdirsyncer/cli/utils.py b/vdirsyncer/cli/utils.py index f12f898..27589d4 100644 --- a/vdirsyncer/cli/utils.py +++ b/vdirsyncer/cli/utils.py @@ -136,7 +136,7 @@ def handle_cli_error(status_name=None, e=None): 'the issue tracker at {}' .format(e, BUGTRACKER_HOME) ) - except exceptions.CollectionRequired as e: + except exceptions.CollectionRequired: cli_logger.error( 'One or more storages don\'t support `collections = null`. ' 'You probably want to set `collections = ["from a", "from b"]`.' @@ -214,7 +214,7 @@ def manage_sync_status(base_path, pair_name, collection_name): f.seek(0) # json.load doesn't work on binary files for Python 3.5 legacy_status = dict(json.loads(f.read().decode('utf-8'))) - except (OSError, IOError, ValueError): + except (OSError, ValueError): pass if legacy_status is not None: diff --git a/vdirsyncer/storage/etesync.py b/vdirsyncer/storage/etesync.py index a390cbd..fec2f3d 100644 --- a/vdirsyncer/storage/etesync.py +++ b/vdirsyncer/storage/etesync.py @@ -76,7 +76,7 @@ class _Session: try: with open(self._auth_token_path) as f: return f.read().strip() or None - except (OSError, IOError): + except OSError: pass def _set_auth_token(self, token): @@ -89,7 +89,7 @@ class _Session: try: with open(self._key_path, 'rb') as f: return f.read() - except (OSError, IOError): + except OSError: pass def _set_key(self, content): diff --git a/vdirsyncer/storage/filesystem.py b/vdirsyncer/storage/filesystem.py index 67892e9..bb051d5 100644 --- a/vdirsyncer/storage/filesystem.py +++ b/vdirsyncer/storage/filesystem.py @@ -89,7 +89,7 @@ class FilesystemStorage(Storage): with open(fpath, 'rb') as f: return (Item(f.read().decode(self.encoding)), get_etag_from_file(fpath)) - except IOError as e: + except OSError as e: if e.errno == errno.ENOENT: raise exceptions.NotFoundError(href) else: @@ -172,7 +172,7 @@ class FilesystemStorage(Storage): try: with open(fpath, 'rb') as f: return normalize_meta_value(f.read().decode(self.encoding)) - except IOError as e: + except OSError as e: if e.errno == errno.ENOENT: return u'' else: diff --git a/vdirsyncer/storage/google.py b/vdirsyncer/storage/google.py index 8558f3b..8096df9 100644 --- a/vdirsyncer/storage/google.py +++ b/vdirsyncer/storage/google.py @@ -50,7 +50,7 @@ class GoogleSession(dav.DAVSession): try: with open(token_file) as f: token = json.load(f) - except (OSError, IOError): + except OSError: pass except ValueError as e: raise exceptions.UserError( diff --git a/vdirsyncer/storage/singlefile.py b/vdirsyncer/storage/singlefile.py index dfad262..1e13f20 100644 --- a/vdirsyncer/storage/singlefile.py +++ b/vdirsyncer/storage/singlefile.py @@ -105,7 +105,7 @@ class SingleFileStorage(Storage): except OSError as e: import errno if e.errno != errno.ENOENT: # file not found - raise IOError(e) + raise OSError(e) text = None if not text: diff --git a/vdirsyncer/utils.py b/vdirsyncer/utils.py index 6527eff..f3b5d43 100644 --- a/vdirsyncer/utils.py +++ b/vdirsyncer/utils.py @@ -127,7 +127,7 @@ def checkdir(path, create=False, mode=0o750): if not os.path.isdir(path): if os.path.exists(path): - raise IOError('{} is not a directory.'.format(path)) + raise OSError('{} is not a directory.'.format(path)) if create: os.makedirs(path, mode) else: @@ -145,7 +145,7 @@ def checkfile(path, create=False): checkdir(os.path.dirname(path), create=create) if not os.path.isfile(path): if os.path.exists(path): - raise IOError('{} is not a file.'.format(path)) + raise OSError('{} is not a file.'.format(path)) if create: with open(path, 'wb'): pass