Skip to content

Commit 68a1459

Browse files
Fix some warnings.
1 parent 677a647 commit 68a1459

File tree

5 files changed

+28
-37
lines changed

5 files changed

+28
-37
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: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
This is borrowed essentially wholesale from scriptabit by DeeDee (see README).
44
"""
55
# 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 *
6+
# from __future__ import (
7+
# absolute_import,
8+
# division,
9+
# print_function,
10+
# unicode_literals)
11+
# from builtins import *
1212
from datetime import datetime
1313
import copy
14-
import time
15-
# from tzlocal import get_localzone
1614
import pytz
1715

1816
from dates import parse_date_utc
@@ -68,7 +66,7 @@ def due(self):
6866
return date
6967
elif self.__task_dict['type'] == 'daily':
7068
if self.__task_dict['isDue'] == True:
71-
date = datetime.now().replace(tzinfo=pytz.utc,hour=0,minute=0,second=0,microsecond=0)
69+
date = datetime.now().replace(tzinfo=pytz.utc, hour=0, minute=0, second=0, microsecond=0)
7270
elif self.__task_dict['nextDue'] != '':
7371
date = parser.parse(self.__task_dict['nextDue'][0])
7472
return date
@@ -78,8 +76,6 @@ def due(self):
7876
@property
7977
def starting(self):
8078
"""When did the daily start running? (That is, is it active now?)"""
81-
from dateutil import parser
82-
import datetime
8379
if self.__task_dict['type'] == 'daily':
8480
start = parser.parse(self.__task_dictself.__task_dict['startDate'])
8581
else:
@@ -137,7 +133,6 @@ def dailies_due(self):
137133
@property
138134
#Is this task due today?
139135
def due_now(self):
140-
now = time.strftime()
141136
if self.__task_dict['type'] == 'daily':
142137
return ''
143138
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: 1 addition & 0 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...

source/todo_task.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22
""" Implements a Todoist synchronisation task.
33
"""
44
# 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-
5+
# from __future__ import (
6+
# absolute_import,
7+
# division,
8+
# print_function,
9+
# unicode_literals)
10+
# from builtins import *
11+
from datetime import datetime, timedelta
12+
from dateutil import parser
13+
import pytz
14+
import main
1515
#from .dates import parse_date_utc
1616
#from .task import CharacterAttribute, ChecklistItem, Difficulty, Task
1717

1818
"""
1919
So what if I did todoist work a sliiiightly different way, using all my task IDs?
2020
"""
2121

22-
class TodTask(object):
22+
23+
class TodTask():
2324
def __init__(self, task=None):
2425
""" Initialise the task.
2526
@@ -70,7 +71,6 @@ def id(self):
7071
@property
7172
#task name
7273
def history(self):
73-
import main
7474
tod_user = main.tod_login('auth.cfg')
7575
activity = tod_user.activity.get(object_type='item', object_id = self.__task_dict['id'], event_type='completed')
7676
return activity
@@ -125,20 +125,17 @@ def due_date(self, date):
125125
@property
126126
#due date
127127
def due(self):
128-
from dateutil import parser
129-
import datetime
130128
if self.__task_dict['due'] is not None:
131-
date = parser.parse(self.__task_dict['due']['date'])
129+
if isinstance(self.__task_dict['due'], dict):
130+
date = parser.parse(self.__task_dict['due']['date'])
131+
else:
132+
date = self.__task_dict['due']
132133
return date
133134
return ''
134135

135136
@property
136137
#is it due TODAY?
137138
def dueToday(self):
138-
from dateutil import parser
139-
from datetime import datetime
140-
from datetime import timedelta
141-
import pytz
142139
today = datetime.utcnow().replace(tzinfo=pytz.UTC)
143140
try:
144141
# that datetime thing is pulling todoist's due dates to my time zone
@@ -163,9 +160,6 @@ def date_string(self):
163160
@property
164161
#should it be due today?
165162
def dueLater(self):
166-
from dateutil import parser
167-
import datetime
168-
import pytz
169163
today = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
170164
try:
171165
wobble = parser.parse(self.__task_dict['due'])

0 commit comments

Comments
 (0)