Skip to content

Commit

Permalink
Make flake8 happy
Browse files Browse the repository at this point in the history
Ignore new flake8 warnings and fix some style issues.
  • Loading branch information
geier authored Nov 1, 2018
1 parent f97c205 commit 1bc431f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion khal/khalendar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from .khalendar import CalendarCollection # flake8: noqa
from .khalendar import CalendarCollection # noqa: F401
6 changes: 3 additions & 3 deletions khal/khalendar/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import datetime as dt
import logging
import os
from collections import defaultdict

import icalendar
import pytz
Expand Down Expand Up @@ -138,7 +137,7 @@ def fromVEvents(cls, events_list, ref=None, **kwargs):
if ref is None:
ref = 'PROTO' if ref in vevents.keys() else list(vevents.keys())[0]
try:
if type(vevents[ref]['DTSTART'].dt) != type(vevents[ref]['DTEND'].dt): # flake8: noqa
if type(vevents[ref]['DTSTART'].dt) != type(vevents[ref]['DTEND'].dt): # noqa: E721
raise ValueError('DTSTART and DTEND should be of the same type (datetime or date)')
except KeyError:
pass
Expand Down Expand Up @@ -382,7 +381,8 @@ def _can_handle_alarm(alarm):
"""
Decides whether we can handle a certain alarm.
"""
return alarm.get('ACTION') == 'DISPLAY' and isinstance(alarm.get('TRIGGER').dt, dt.timedelta)
return alarm.get('ACTION') == 'DISPLAY' and \
isinstance(alarm.get('TRIGGER').dt, dt.timedelta)

@property
def alarms(self):
Expand Down
8 changes: 4 additions & 4 deletions tests/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,10 @@ def test_print_ics_command(runner):
# Non existing file
result = runner.invoke(main_khal, ['printics', 'nonexisting_file'])
assert result.exception
assert ('Error: Invalid value for "ics": Could not open file: ' \
in result.output or \
'Error: Invalid value for "[ICS]": Could not open file:' \
in result.output)
assert (
'Error: Invalid value for "ics": Could not open file: ' in result.output or
'Error: Invalid value for "[ICS]": Could not open file:'
in result.output)

# Run on test files
result = runner.invoke(main_khal, ['printics', _get_ics_filepath('cal_d')])
Expand Down
90 changes: 45 additions & 45 deletions tests/parse_datetime_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_short_format_contains_year(self):
'longdatetimeformat': '%Y-%m-%d %H:%M',
}
assert (dt.datetime(2017, 1, 1), True) == guessdatetimefstr(
'2017-1-1'.split(), locale=locale, default_day=dt.datetime.today())
'2017-1-1'.split(), locale=locale, default_day=dt.datetime.today())
assert (dt.datetime(2017, 1, 1, 16, 30), False) == guessdatetimefstr(
'2017-1-1 16:30'.split(), locale=locale, default_day=dt.datetime.today())

Expand Down Expand Up @@ -326,55 +326,55 @@ def test_short_format_contains_year(self):
# start and end date same, no explicit end date given
('25.10.2013 18:00 20:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T200000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T200000')),

# start and end date same, ends 24:00 which should be 00:00 (start) of next
# day
('25.10.2013 18:00 24:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131026T000000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131026T000000')),

# start and end date same, explicit end date (but no year) given
('25.10.2013 18:00 26.10. 20:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131026T200000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131026T200000')),

('30.12.2013 18:00 2.1. 20:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131230T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140102T200000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131230T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140102T200000')),

# only start date given (no year, past day and month)
('25.01. 18:00 20:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20150125T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20150125T200000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20150125T180000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20150125T200000')),

# date ends next day, but end date not given
('25.10.2013 23:00 0:30 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T230000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131026T003000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T230000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131026T003000')),

('2.2. 23:00 0:30 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20150202T230000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20150203T003000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20150202T230000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20150203T003000')),

# only start datetime given
('25.10.2013 06:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T060000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T070000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T060000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20131025T070000')),

# timezone given
('25.10.2013 06:00 America/New_York Äwesöme Event',
_create_vevent(
'DTSTART;TZID=America/New_York;VALUE=DATE-TIME:20131025T060000',
'DTEND;TZID=America/New_York;VALUE=DATE-TIME:20131025T070000'))
'DTSTART;TZID=America/New_York;VALUE=DATE-TIME:20131025T060000',
'DTEND;TZID=America/New_York;VALUE=DATE-TIME:20131025T070000'))
)


Expand All @@ -388,8 +388,8 @@ def test_construct_event_format_de():
test_set_format_us = _create_testcases(
('1999/12/31-06:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=America/New_York;VALUE=DATE-TIME:19991231T060000',
'DTEND;TZID=America/New_York;VALUE=DATE-TIME:19991231T070000')),
'DTSTART;TZID=America/New_York;VALUE=DATE-TIME:19991231T060000',
'DTEND;TZID=America/New_York;VALUE=DATE-TIME:19991231T070000')),

('2014/12/18 2014/12/20 Äwesöme Event',
_create_vevent('DTSTART;VALUE=DATE:20141218',
Expand All @@ -409,20 +409,20 @@ def test__construct_event_format_us():
# today
('8:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T080000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T090000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T080000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T090000')),

# today until tomorrow
('22:00 1:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T220000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140217T010000')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T220000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140217T010000')),

# other timezone
('22:00 1:00 Europe/London Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/London;VALUE=DATE-TIME:20140216T220000',
'DTEND;TZID=Europe/London;VALUE=DATE-TIME:20140217T010000')),
'DTSTART;TZID=Europe/London;VALUE=DATE-TIME:20140216T220000',
'DTEND;TZID=Europe/London;VALUE=DATE-TIME:20140217T010000')),

('15.06. Äwesöme Event',
_create_vevent('DTSTART;VALUE=DATE:20140615',
Expand All @@ -440,9 +440,9 @@ def test__construct_event_format_de_complexer():
test_set_leap_year = _create_testcases(
('29.02. Äwesöme Event',
_create_vevent(
'DTSTART;VALUE=DATE:20160229',
'DTEND;VALUE=DATE:20160301',
'DTSTAMP;VALUE=DATE-TIME:20160101T202122Z')),
'DTSTART;VALUE=DATE:20160229',
'DTEND;VALUE=DATE:20160301',
'DTSTAMP;VALUE=DATE-TIME:20160101T202122Z')),
)


Expand All @@ -461,16 +461,16 @@ def test_leap_year():
# today
('8:00 Äwesöme Event :: this is going to be awesome',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T080000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T090000',
'DESCRIPTION:this is going to be awesome')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T080000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T090000',
'DESCRIPTION:this is going to be awesome')),

# today until tomorrow
('22:00 1:00 Äwesöme Event :: Will be even better',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T220000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140217T010000',
'DESCRIPTION:Will be even better')),
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T220000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140217T010000',
'DESCRIPTION:Will be even better')),

('15.06. Äwesöme Event :: and again',
_create_vevent('DTSTART;VALUE=DATE:20140615',
Expand All @@ -491,10 +491,10 @@ def test_description():
# today
('8:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T080000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T090000',
'DESCRIPTION:please describe the event',
'RRULE:FREQ=DAILY;UNTIL=20150605T000000')))
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T080000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T090000',
'DESCRIPTION:please describe the event',
'RRULE:FREQ=DAILY;UNTIL=20150605T000000')))


def test_repeat():
Expand Down Expand Up @@ -541,11 +541,11 @@ def test_alarm():
# today
('8:00 Äwesöme Event',
_create_vevent(
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T080000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T090000',
'CATEGORIES:boring meeting',
'DESCRIPTION:please describe the event',
'LOCATION:in the office')))
'DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T080000',
'DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140216T090000',
'CATEGORIES:boring meeting',
'DESCRIPTION:please describe the event',
'LOCATION:in the office')))


@freeze_time('2014-02-16 12:00:00')
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ skip_install=True
whitelist_externals = sh
deps = flake8
commands =
flake8 tests khal setup.py
flake8 --ignore E252,W504,E121 tests khal setup.py
sh -c '! grep -ri seperat */*'

[testenv:docs]
Expand All @@ -52,4 +52,4 @@ commands =

[flake8]
max-line-length = 100
exclude=.tox,examples,doc
exclude = .tox,examples,doc

0 comments on commit 1bc431f

Please sign in to comment.