Skip to content

Commit

Permalink
Fix ruff rule violations
Browse files Browse the repository at this point in the history
E401 Multiple imports on one line
E701 Multiple statements on one line (colon)
E713 Test for membership should be `not in`
F401 `foo` imported but unused
F405 `foo` may be undefined, or defined from star imports
F821 Undefined name `foo`
F841 Local variable `foo` is assigned to but never used
  • Loading branch information
skangas committed Sep 1, 2023
1 parent f1679bf commit d2f812b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
17 changes: 10 additions & 7 deletions lieer/gmailieer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os, sys
import os
import sys
import argparse
from oauth2client import tools
import googleapiclient
import googleapiclient.errors
import notmuch2

from .remote import *
from .local import *
from .remote import Remote
from .local import Local

class Gmailieer:
cwd = None
Expand Down Expand Up @@ -460,12 +461,13 @@ def partial_pull (self):
else:
raise

except Remote.NoHistoryException as excep:
except Remote.NoHistoryException:
print ("pull: failed, re-try in a bit.")
raise

finally:
if bar is not None: self.bar_close ()
if bar is not None:
self.bar_close()

# figure out which changes need to be applied
added_messages = [] # added messages, if they are later deleted they will be
Expand Down Expand Up @@ -556,7 +558,8 @@ def remove_from_list (lst, m):

self.bar_update (1)

if bar: self.bar_close ()
if bar:
self.bar_close ()

changed = False
# fetching new messages
Expand Down Expand Up @@ -785,7 +788,7 @@ def load_resume(self, f, lastid):
if os.path.exists(f):
try:
return ResumePull.load(f)
except ex:
except Exception as ex:
self.vprint("failed to load resume file, creating new: %s" % ex)
return ResumePull.new(f, lastid)
else:
Expand Down
7 changes: 4 additions & 3 deletions lieer/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os, shutil, fcntl
import os
import shutil
import fcntl
import json
import base64
import configparser
from pathlib import Path
import tempfile

Expand Down Expand Up @@ -497,7 +498,7 @@ def __make_maildir_name__ (self, m, labels):
# if 'TRASH' in labels:
# info += 'T'

if not 'UNREAD' in labels:
if 'UNREAD' not in labels:
info += 'S'

return p + info
Expand Down
8 changes: 4 additions & 4 deletions lieer/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from oauth2client import client
from oauth2client import tools
from oauth2client.file import Storage
from pathlib import Path

class Remote:
SCOPES = 'https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.labels https://www.googleapis.com/auth/gmail.modify'
Expand Down Expand Up @@ -350,14 +349,14 @@ def _cb (rid, resp, excep):

conn_errors = 0

except Remote.UserRateException as ex:
except Remote.UserRateException:
user_rate_delay = user_rate_delay * 2 + 1
print ("remote: user rate error, increasing delay to %s" % user_rate_delay)
user_rate_ok = 0

i = j # reset

except Remote.BatchException as ex:
except Remote.BatchException:
max_req = max_req // 2
req_ok = 0

Expand Down Expand Up @@ -416,7 +415,8 @@ def authorize (self, reauth = False):
self.credentials = self.__get_credentials__ ()

timeout = self.gmailieer.local.config.timeout
if timeout == 0: timeout = None
if timeout == 0:
timeout = None

self.http = self.credentials.authorize (httplib2.Http(timeout = timeout))
self.service = discovery.build ('gmail', 'v1', http = self.http)
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
import tempfile

class MockGmi:
dry_run = False
Expand Down
2 changes: 1 addition & 1 deletion tests/test_local.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import *
import pytest
import lieer


Expand Down

0 comments on commit d2f812b

Please sign in to comment.