diff options
author | Hugo Osvaldo Barrera <hugo@whynothugo.nl> | 2023-02-10 17:12:07 +0100 |
---|---|---|
committer | Hugo <hugo@whynothugo.nl> | 2023-05-24 14:20:00 +0200 |
commit | 304e26974ad93620b6132d181321e8fb11d2968a (patch) | |
tree | dc98146f64dce4e037bcfe923e527adb6a80dcbd | |
parent | f37b28a607c913a906c371366fac75ab242edec6 (diff) |
Use ruff for managing imports too
-rw-r--r-- | .pre-commit-config.yaml | 5 | ||||
-rw-r--r-- | khal/configwizard.py | 3 | ||||
-rw-r--r-- | khal/controllers.py | 6 | ||||
-rw-r--r-- | khal/khalendar/backend.py | 3 | ||||
-rw-r--r-- | khal/khalendar/khalendar.py | 23 | ||||
-rw-r--r-- | khal/khalendar/vdir.py | 3 | ||||
-rw-r--r-- | khal/settings/settings.py | 21 | ||||
-rw-r--r-- | khal/ui/__init__.py | 3 | ||||
-rw-r--r-- | khal/ui/editor.py | 18 | ||||
-rw-r--r-- | pyproject.toml | 2 | ||||
-rw-r--r-- | tests/cal_display_test.py | 9 | ||||
-rw-r--r-- | tests/event_test.py | 18 | ||||
-rw-r--r-- | tests/khalendar_test.py | 17 | ||||
-rw-r--r-- | tests/parse_datetime_test.py | 22 | ||||
-rw-r--r-- | tests/settings_test.py | 13 |
15 files changed, 109 insertions, 57 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 84dae0b4..422840f0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,11 +8,6 @@ repos: - id: check-toml - id: check-added-large-files - id: debug-statements - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - name: isort (python) - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.0.0 hooks: diff --git a/khal/configwizard.py b/khal/configwizard.py index 0ef4965a..7590f81b 100644 --- a/khal/configwizard.py +++ b/khal/configwizard.py @@ -26,8 +26,7 @@ import logging from functools import partial from itertools import zip_longest from os import environ, makedirs -from os.path import (dirname, exists, expanduser, expandvars, isdir, join, - normpath) +from os.path import dirname, exists, expanduser, expandvars, isdir, join, normpath from subprocess import call import xdg diff --git a/khal/controllers.py b/khal/controllers.py index 8054874a..b1434e0f 100644 --- a/khal/controllers.py +++ b/khal/controllers.py @@ -32,8 +32,7 @@ from typing import List, Optional import pytz from click import confirm, echo, prompt, style -from khal import (__productname__, __version__, calendar_display, - parse_datetime, utils) +from khal import __productname__, __version__, calendar_display, parse_datetime, utils from khal.custom_types import EventCreationTypes, LocaleConfiguration from khal.exceptions import DateTimeParseError, FatalError from khal.khalendar import CalendarCollection @@ -41,9 +40,8 @@ from khal.khalendar.event import Event from khal.khalendar.exceptions import DuplicateUid, ReadOnlyCalendarError from .exceptions import ConfigurationError -from .icalendar import cal_from_ics +from .icalendar import cal_from_ics, split_ics from .icalendar import sort_key as sort_vevent_key -from .icalendar import split_ics from .khalendar.vdir import Item from .terminal import merge_columns diff --git a/khal/khalendar/backend.py b/khal/khalendar/backend.py index 89ede3dd..25b3b29d 100644 --- a/khal/khalendar/backend.py +++ b/khal/khalendar/backend.py @@ -41,8 +41,7 @@ from ..icalendar import assert_only_one_uid, cal_from_ics from ..icalendar import expand as expand_vevent from ..icalendar import sanitize as sanitize_vevent from ..icalendar import sort_key as sort_vevent_key -from .exceptions import (CouldNotCreateDbDir, NonUniqueUID, - OutdatedDbVersionError, UpdateFailed) +from .exceptions import CouldNotCreateDbDir, NonUniqueUID, OutdatedDbVersionError, UpdateFailed logger = logging.getLogger('khal') diff --git a/khal/khalendar/khalendar.py b/khal/khalendar/khalendar.py index 31b50ccb..5814c259 100644 --- a/khal/khalendar/khalendar.py +++ b/khal/khalendar/khalendar.py @@ -30,18 +30,27 @@ import itertools import logging import os import os.path -from typing import (Any, Dict, Iterable, List, Optional, Set, Tuple, # noqa - Union) +from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Union # noqa from ..custom_types import CalendarConfiguration, EventCreationTypes from ..icalendar import new_vevent from . import backend from .event import Event -from .exceptions import (DuplicateUid, EtagMissmatch, NonUniqueUID, - ReadOnlyCalendarError, UnsupportedFeatureError, - UpdateFailed) -from .vdir import (AlreadyExistingError, CollectionNotFoundError, Vdir, - WrongEtagError, get_etag_from_file) +from .exceptions import ( + DuplicateUid, + EtagMissmatch, + NonUniqueUID, + ReadOnlyCalendarError, + UnsupportedFeatureError, + UpdateFailed, +) +from .vdir import ( + AlreadyExistingError, + CollectionNotFoundError, + Vdir, + WrongEtagError, + get_etag_from_file, +) logger = logging.getLogger('khal') diff --git a/khal/khalendar/vdir.py b/khal/khalendar/vdir.py index b442d5d3..5e819ad2 100644 --- a/khal/khalendar/vdir.py +++ b/khal/khalendar/vdir.py @@ -7,8 +7,7 @@ import errno import os import uuid from hashlib import sha1 -from typing import (IO, Callable, Dict, Iterable, Optional, Protocol, Tuple, - Type) +from typing import IO, Callable, Dict, Iterable, Optional, Protocol, Tuple, Type from atomicwrites import atomic_write diff --git a/khal/settings/settings.py b/khal/settings/settings.py index 0683a39b..2b0cdebb 100644 --- a/khal/settings/settings.py +++ b/khal/settings/settings.py @@ -24,8 +24,7 @@ import logging import os import xdg.BaseDirectory -from configobj import (ConfigObj, ConfigObjError, flatten_errors, - get_extra_values) +from configobj import ConfigObj, ConfigObjError, flatten_errors, get_extra_values from khal import __productname__ @@ -37,11 +36,19 @@ except ModuleNotFoundError: from typing import Callable, List, Optional -from .exceptions import (CannotParseConfigFileError, InvalidSettingsError, - NoConfigFile) -from .utils import (config_checks, expand_db_path, expand_path, - get_color_from_vdir, get_vdir_type, is_color, is_timedelta, - is_timezone, monthdisplay_option, weeknumber_option) +from .exceptions import CannotParseConfigFileError, InvalidSettingsError, NoConfigFile +from .utils import ( + config_checks, + expand_db_path, + expand_path, + get_color_from_vdir, + get_vdir_type, + is_color, + is_timedelta, + is_timezone, + monthdisplay_option, + weeknumber_option, +) logger = logging.getLogger('khal') SPECPATH = os.path.join(os.path.dirname(__file__), 'khal.spec') diff --git a/khal/ui/__init__.py b/khal/ui/__init__.py index 0908a4b4..36b096d3 100644 --- a/khal/ui/__init__.py +++ b/khal/ui/__init__.py @@ -33,9 +33,8 @@ from ..khalendar.exceptions import ReadOnlyCalendarError from . import colors from .base import Pane, Window from .editor import EventEditor, ExportDialog -from .widgets import CalendarWidget +from .widgets import CalendarWidget, NColumns, NPile, linebox from .widgets import ExtendedEdit as Edit -from .widgets import NColumns, NPile, linebox logger = logging.getLogger('khal') diff --git a/khal/ui/editor.py b/khal/ui/editor.py index 3edf3b0c..2ea3c006 100644 --- a/khal/ui/editor.py +++ b/khal/ui/editor.py @@ -24,10 +24,20 @@ import datetime as dt import urwid from ..utils import get_weekday_occurrence, get_wrapped_text -from .widgets import (AlarmsEditor, CalendarWidget, Choice, - DateConversionError, DateWidget, ExtendedEdit, NColumns, - NListBox, NPile, PositiveIntEdit, TimeWidget, - ValidatedEdit) +from .widgets import ( + AlarmsEditor, + CalendarWidget, + Choice, + DateConversionError, + DateWidget, + ExtendedEdit, + NColumns, + NListBox, + NPile, + PositiveIntEdit, + TimeWidget, + ValidatedEdit, +) class StartEnd: diff --git a/pyproject.toml b/pyproject.toml index 537cc6ed..5c804393 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.ruff] -select = ["E", "F", "W", "B0", "UP", "C4"] +select = ["E", "F", "W", "I", "B0", "UP", "C4"] ignore = ["B008"] line-length = 100 target-version = "py38" diff --git a/tests/cal_display_test.py b/tests/cal_display_test.py index 26951c09..cac5488f 100644 --- a/tests/cal_display_test.py +++ b/tests/cal_display_test.py @@ -5,8 +5,13 @@ import unicodedata import pytest -from khal.calendar_display import (get_calendar_color, get_color_list, - getweeknumber, str_week, vertical_month) +from khal.calendar_display import ( + get_calendar_color, + get_color_list, + getweeknumber, + str_week, + vertical_month, +) today = dt.date.today() yesterday = today - dt.timedelta(days=1) diff --git a/tests/event_test.py b/tests/event_test.py index cb202cb5..34e33043 100644 --- a/tests/event_test.py +++ b/tests/event_test.py @@ -8,11 +8,19 @@ from hypothesis.strategies import datetimes from icalendar import Parameters, vCalAddress, vRecur, vText from packaging import version -from khal.khalendar.event import (AllDayEvent, Event, FloatingEvent, - LocalizedEvent, create_timezone) - -from .utils import (BERLIN, BOGOTA, GMTPLUS3, LOCALE_BERLIN, LOCALE_BOGOTA, - LOCALE_MIXED, NEW_YORK, _get_text, normalize_component) +from khal.khalendar.event import AllDayEvent, Event, FloatingEvent, LocalizedEvent, create_timezone + +from .utils import ( + BERLIN, + BOGOTA, + GMTPLUS3, + LOCALE_BERLIN, + LOCALE_BOGOTA, + LOCALE_MIXED, + NEW_YORK, + _get_text, + normalize_component, +) EVENT_KWARGS = {'calendar': 'foobar', 'locale': LOCALE_BERLIN} diff --git a/tests/khalendar_test.py b/tests/khalendar_test.py index ac26ea6e..2915b62c 100644 --- a/tests/khalendar_test.py +++ b/tests/khalendar_test.py @@ -16,9 +16,20 @@ from khal.khalendar.event import Event from khal.khalendar.vdir import Item from . import utils -from .utils import (BERLIN, LOCALE_BERLIN, LOCALE_SYDNEY, LONDON, SYDNEY, - CollVdirType, DumbItem, _get_text, cal1, cal2, cal3, - normalize_component) +from .utils import ( + BERLIN, + LOCALE_BERLIN, + LOCALE_SYDNEY, + LONDON, + SYDNEY, + CollVdirType, + DumbItem, + _get_text, + cal1, + cal2, + cal3, + normalize_component, +) today = dt.date.today() yesterday = today - dt.timedelta(days=1) diff --git a/tests/parse_datetime_test.py b/tests/parse_datetime_test.py index e798a577..e40507a8 100644 --- a/tests/parse_datetime_test.py +++ b/tests/parse_datetime_test.py @@ -6,13 +6,23 @@ from freezegun import freeze_time from khal.exceptions import DateTimeParseError, FatalError from khal.icalendar import new_vevent -from khal.parse_datetime import (construct_daynames, eventinfofstr, - guessdatetimefstr, guessrangefstr, - guesstimedeltafstr, timedelta2str, - weekdaypstr) +from khal.parse_datetime import ( + construct_daynames, + eventinfofstr, + guessdatetimefstr, + guessrangefstr, + guesstimedeltafstr, + timedelta2str, + weekdaypstr, +) -from .utils import (LOCALE_BERLIN, LOCALE_FLOATING, LOCALE_NEW_YORK, - _replace_uid, normalize_component) +from .utils import ( + LOCALE_BERLIN, + LOCALE_FLOATING, + LOCALE_NEW_YORK, + _replace_uid, + normalize_component, +) def _create_testcases(*cases): diff --git a/tests/settings_test.py b/tests/settings_test.py index b9b411ab..22dec970 100644 --- a/tests/settings_test.py +++ b/tests/settings_test.py @@ -5,11 +5,14 @@ import pytest from tzlocal import get_localzone as _get_localzone from khal.settings import get_config -from khal.settings.exceptions import (CannotParseConfigFileError, - InvalidSettingsError) -from khal.settings.utils import (config_checks, get_all_vdirs, - get_color_from_vdir, get_unique_name, - is_color) +from khal.settings.exceptions import CannotParseConfigFileError, InvalidSettingsError +from khal.settings.utils import ( + config_checks, + get_all_vdirs, + get_color_from_vdir, + get_unique_name, + is_color, +) try: # Available from configobj 5.1.0 |