Skip to content

Commit 2e64481

Browse files
Fix some warnings. Remove unneeded imports.
1 parent c5f0d8a commit 2e64481

File tree

5 files changed

+21
-43
lines changed

5 files changed

+21
-43
lines changed

.github/workflows/codacy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ name: Codacy Security Scan
1515

1616
on:
1717
push:
18-
branches:
18+
branches:
1919
- master
2020
- develop
21+
- fix-warnings-2
2122
pull_request:
2223
# The branches below must be a subset of the branches above
23-
branches:
24+
branches:
2425
- master
2526
- develop
2627

source/hab_task.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,8 @@
22
""" Implements a Habitica synchronisation task.
33
This is borrowed essentially wholesale from scriptabit by DeeDee (see README).
44
"""
5-
# Ensure backwards compatibility with Python 2
6-
from __future__ import (
7-
absolute_import,
8-
division,
9-
print_function,
10-
unicode_literals)
11-
from builtins import *
125
from datetime import datetime
136
import copy
14-
import time
15-
# from tzlocal import get_localzone
167
import pytz
178

189
from dates import parse_date_utc
@@ -68,7 +59,7 @@ def due(self):
6859
return date
6960
elif self.__task_dict['type'] == 'daily':
7061
if self.__task_dict['isDue'] == True:
71-
date = datetime.now().replace(tzinfo=pytz.utc,hour=0,minute=0,second=0,microsecond=0)
62+
date = datetime.now().replace(tzinfo=pytz.utc, hour=0, minute=0, second=0, microsecond=0)
7263
elif self.__task_dict['nextDue'] != '':
7364
date = parser.parse(self.__task_dict['nextDue'][0])
7465
return date
@@ -78,8 +69,6 @@ def due(self):
7869
@property
7970
def starting(self):
8071
"""When did the daily start running? (That is, is it active now?)"""
81-
from dateutil import parser
82-
import datetime
8372
if self.__task_dict['type'] == 'daily':
8473
start = parser.parse(self.__task_dictself.__task_dict['startDate'])
8574
else:
@@ -137,7 +126,6 @@ def dailies_due(self):
137126
@property
138127
#Is this task due today?
139128
def due_now(self):
140-
now = time.strftime()
141129
if self.__task_dict['type'] == 'daily':
142130
return ''
143131
else:

source/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pickle
99
import time
1010
import requests
11-
from dateutil import parser
11+
# from dateutil import parser
1212
from hab_task import HabTask
1313
import config
1414

source/one_way_sync.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def complete_todoist(todo_api, task_id):
5252

5353

5454
def sync_todoist_to_habitica():
55+
'''Main function for syncing one-way from Todoist to Habitica '''
5556
# todayFilter = todo_api.filters.add('todayFilter', 'today')
5657

5758
# Telling the site where the config stuff for Habitica can go and get a list of habitica tasks...
@@ -179,7 +180,7 @@ def sync_todoist_to_habitica():
179180
continue
180181
else:
181182
print("error, check todoist daily")
182-
elif hab.dueToday == False:
183+
elif not hab.dueToday:
183184
try:
184185
match_dict[tid]['duelast']
185186
except:
@@ -188,7 +189,7 @@ def sync_todoist_to_habitica():
188189
# this is me keeping a record of recurring tods being completed or not for some of
189190
# the complicated bits
190191
match_dict[tid]['duelast'] = 'Yes'
191-
if hab.completed == False:
192+
if not hab.completed:
192193
if match_dict[tid]['duelast'] == 'Yes':
193194
if tod.dueToday == 'No':
194195
response = main.complete_hab(hab)
@@ -219,7 +220,7 @@ def sync_todoist_to_habitica():
219220
print("ERROR: check HAB %s" % tid)
220221
# match_dict.pop(tid)
221222
elif tod.complete == 1:
222-
if hab.completed == False:
223+
if not hab.completed:
223224
response = main.complete_hab(hab)
224225
print(response)
225226
if response.ok:

source/todo_task.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
# -*- coding: utf-8 -*-
22
""" Implements a Todoist synchronisation task.
33
"""
4-
# Ensure backwards compatibility with Python 2
5-
from __future__ import (
6-
absolute_import,
7-
division,
8-
print_function,
9-
unicode_literals)
10-
from builtins import *
11-
from datetime import datetime
12-
from tzlocal import get_localzone
13-
14-
4+
from datetime import datetime, timedelta
5+
import pytz
6+
from dateutil import parser
7+
import main
158
#from .dates import parse_date_utc
169
#from .task import CharacterAttribute, ChecklistItem, Difficulty, Task
1710

1811
"""
1912
So what if I did todoist work a sliiiightly different way, using all my task IDs?
2013
"""
2114

22-
class TodTask(object):
15+
16+
class TodTask():
17+
'''Hold a Todoist task '''
2318
def __init__(self, task=None):
2419
""" Initialise the task.
2520
@@ -70,7 +65,6 @@ def id(self):
7065
@property
7166
#task name
7267
def history(self):
73-
import main
7468
tod_user = main.tod_login('auth.cfg')
7569
activity = tod_user.activity.get(object_type='item', object_id = self.__task_dict['id'], event_type='completed')
7670
return activity
@@ -125,20 +119,17 @@ def due_date(self, date):
125119
@property
126120
#due date
127121
def due(self):
128-
from dateutil import parser
129-
import datetime
130122
if self.__task_dict['due'] is not None:
131-
date = parser.parse(self.__task_dict['due']['date'])
123+
if isinstance(self.__task_dict['due'], dict):
124+
date = parser.parse(self.__task_dict['due']['date'])
125+
else:
126+
date = self.__task_dict['due']
132127
return date
133128
return ''
134129

135130
@property
136131
#is it due TODAY?
137132
def dueToday(self):
138-
from dateutil import parser
139-
from datetime import datetime
140-
from datetime import timedelta
141-
import pytz
142133
today = datetime.utcnow().replace(tzinfo=pytz.UTC)
143134
try:
144135
# that datetime thing is pulling todoist's due dates to my time zone
@@ -163,10 +154,7 @@ def date_string(self):
163154
@property
164155
#should it be due today?
165156
def dueLater(self):
166-
from dateutil import parser
167-
import datetime
168-
import pytz
169-
today = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
157+
today = datetime.utcnow().replace(tzinfo=pytz.UTC)
170158
try:
171159
wobble = parser.parse(self.__task_dict['due'])
172160
dueDate = wobble.date()

0 commit comments

Comments
 (0)