Skip to content

Commit

Permalink
Refactoring: Force automated import sorting for all code
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Stepanov committed Sep 26, 2023
1 parent 5c61818 commit ff35832
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
pip install --upgrade isort
- name: Check imports with isort
run: |
isort --check --diff urwid/event_loop urwid/widget urwid/font.py urwid/escape.py urwid/command_map.py examples
isort --check --diff urwid tests examples
Black:
name: Validate black formatting
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from setuptools import Extension, setup


setup_d = {
'name': "urwid",
'ext_modules': [Extension('urwid.str_util', sources=['source/str_util.c'])],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_vterm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from itertools import dropwhile
from time import sleep

from urwid import Widget, signals, vterm, BoxAdapter
from urwid import BoxAdapter, Widget, signals, vterm
from urwid.listbox import ListBox


Expand Down
10 changes: 1 addition & 9 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@ skip_install = true
deps =
isort
commands =
isort \
urwid/event_loop \
urwid/widget \
urwid/font.py \
urwid/escape.py \
urwid/command_map.py \
urwid/graphics.py \
urwid/numedit.py \
examples
isort urwid tests examples

[testenv:black]
skip_install = true
Expand Down
182 changes: 90 additions & 92 deletions urwid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from __future__ import annotations

from urwid import raw_display
from urwid.canvas import (
BlankCanvas,
Canvas,
Expand All @@ -49,7 +50,32 @@
CommandMap,
command_map,
)

from urwid.display_common import (
BLACK,
BROWN,
DARK_BLUE,
DARK_CYAN,
DARK_GRAY,
DARK_GREEN,
DARK_MAGENTA,
DARK_RED,
DEFAULT,
LIGHT_BLUE,
LIGHT_CYAN,
LIGHT_GRAY,
LIGHT_GREEN,
LIGHT_MAGENTA,
LIGHT_RED,
UPDATE_PALETTE_ENTRY,
WHITE,
YELLOW,
AttrSpec,
AttrSpecError,
BaseScreen,
RealTerminal,
ScreenError,
)
from urwid.event_loop import AsyncioEventLoop, EventLoop, ExitMainLoop, MainLoop, SelectEventLoop
from urwid.font import (
Font,
FontRegistry,
Expand All @@ -64,12 +90,31 @@
Thin6x6Font,
get_all_fonts,
)

from urwid.listbox import ListBox, ListBoxError, ListWalker, ListWalkerError, SimpleFocusListWalker, SimpleListWalker
from urwid.event_loop import EventLoop, AsyncioEventLoop, ExitMainLoop, MainLoop, SelectEventLoop
from urwid.monitored_list import MonitoredFocusList, MonitoredList
from urwid.signals import MetaSignals, Signals, connect_signal, disconnect_signal, emit_signal, register_signal
from urwid.text_layout import LayoutSegment, StandardTextLayout, TextLayout, default_layout
from urwid.util import (
MetaSuper,
TagMarkupException,
apply_target_encoding,
calc_text_pos,
calc_trim_text,
calc_width,
decompose_tagmarkup,
detected_encoding,
get_encoding_mode,
int_scale,
is_mouse_event,
is_wide_char,
move_next_char,
move_prev_char,
set_encoding,
supports_unicode,
within_double_byte,
)
from urwid.version import __version__, __version_tuple__
from urwid.vterm import TermCanvas, TermCharset, Terminal, TermModes, TermScroller
from urwid.widget import (
ANY,
BOTTOM,
Expand All @@ -90,115 +135,68 @@
TOP,
WEIGHT,
Align,
Sizing,
VAlign,
WHSettings,
WrapMode,
BoxWidget,
Divider,
Edit,
EditError,
FixedWidget,
FlowWidget,
IntEdit,
SolidFill,
Text,
TextError,
Widget,
WidgetError,
WidgetMeta,
WidgetWrap,
WidgetWrapError,
delegate_to_widget_mixin,
fixed_size,
WidgetPlaceholder,
AttrMap,
AttrMapError,
AttrWrap,
BarGraph,
BarGraphError,
BarGraphMeta,
BigText,
BoxAdapter,
BoxAdapterError,
WidgetDisable,
BoxWidget,
Button,
CheckBox,
CheckBoxError,
Columns,
ColumnsError,
Divider,
Edit,
EditError,
Filler,
FillerError,
Padding,
PaddingError,
WidgetDecoration,
GridFlow,
GridFlowError,
FixedWidget,
FlowWidget,
Frame,
FrameError,
GraphVScale,
GridFlow,
GridFlowError,
IntEdit,
LineBox,
Overlay,
OverlayError,
Padding,
PaddingError,
Pile,
PileError,
Columns,
ColumnsError,
WidgetContainerMixin,
PopUpLauncher,
PopUpTarget,
Button,
CheckBox,
CheckBoxError,
ProgressBar,
RadioButton,
SelectableIcon,
BigText,
LineBox,
BarGraph,
BarGraphError,
BarGraphMeta,
GraphVScale,
Sizing,
SolidFill,
Text,
TextError,
VAlign,
WHSettings,
Widget,
WidgetContainerMixin,
WidgetDecoration,
WidgetDisable,
WidgetError,
WidgetMeta,
WidgetPlaceholder,
WidgetWrap,
WidgetWrapError,
WrapMode,
delegate_to_widget_mixin,
fixed_size,
scale_bar_values,
ProgressBar,
)

from urwid import raw_display
from urwid.display_common import (
BLACK,
BROWN,
DARK_BLUE,
DARK_CYAN,
DARK_GRAY,
DARK_GREEN,
DARK_MAGENTA,
DARK_RED,
DEFAULT,
LIGHT_BLUE,
LIGHT_CYAN,
LIGHT_GRAY,
LIGHT_GREEN,
LIGHT_MAGENTA,
LIGHT_RED,
UPDATE_PALETTE_ENTRY,
WHITE,
YELLOW,
AttrSpec,
AttrSpecError,
BaseScreen,
RealTerminal,
ScreenError,
)
from urwid.text_layout import LayoutSegment, StandardTextLayout, TextLayout, default_layout
from urwid.treetools import ParentNode, TreeListBox, TreeNode, TreeWalker, TreeWidget, TreeWidgetError
from urwid.util import (
MetaSuper,
TagMarkupException,
apply_target_encoding,
calc_text_pos,
calc_trim_text,
calc_width,
decompose_tagmarkup,
detected_encoding,
get_encoding_mode,
int_scale,
is_mouse_event,
is_wide_char,
move_next_char,
move_prev_char,
set_encoding,
supports_unicode,
within_double_byte,
)
from urwid.vterm import TermCanvas, TermCharset, Terminal, TermModes, TermScroller
from urwid.treetools import ParentNode, TreeListBox, TreeNode, TreeWalker, TreeWidget, TreeWidgetError # isort: skip

# Optional event loops with external dependencies

Expand Down
3 changes: 2 additions & 1 deletion urwid/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import typing
import warnings
import weakref
from collections.abc import Sequence

from urwid.text_layout import LayoutSegment, trim_line
from urwid.util import (
Expand All @@ -40,6 +39,8 @@
)

if typing.TYPE_CHECKING:
from collections.abc import Sequence

from .widget import Widget


Expand Down
5 changes: 3 additions & 2 deletions urwid/display_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@
import sys
import typing
import warnings
from collections.abc import Iterable, Sequence

try:
import termios
except ImportError:
pass # windows
pass # windows

from urwid import signals
from urwid.util import StoppingContext, int_scale

if typing.TYPE_CHECKING:
from collections.abc import Iterable, Sequence

from typing_extensions import Literal, Self

# for replacing unprintable bytes with '?'
Expand Down
3 changes: 2 additions & 1 deletion urwid/lcd_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@

import time
import typing
from collections.abc import Iterable, Sequence

from .display_common import BaseScreen

if typing.TYPE_CHECKING:
from collections.abc import Iterable, Sequence

from typing_extensions import Literal


Expand Down
3 changes: 2 additions & 1 deletion urwid/monitored_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import functools
import typing
import warnings
from collections.abc import Callable

if typing.TYPE_CHECKING:
from collections.abc import Callable

from typing_extensions import ParamSpec

ArgSpec = ParamSpec("ArgSpec")
Expand Down
3 changes: 1 addition & 2 deletions urwid/raw_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

from __future__ import annotations

import io
import os
import select
import signal
Expand All @@ -39,7 +38,7 @@
import termios
import tty
except ImportError:
pass # windows
pass # windows

from subprocess import PIPE, Popen

Expand Down
4 changes: 3 additions & 1 deletion urwid/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import typing
import warnings
import weakref
from collections.abc import Callable, Collection, Container, Iterable

if typing.TYPE_CHECKING:
from collections.abc import Callable, Collection, Container, Iterable


class MetaSignals(type):
Expand Down
1 change: 1 addition & 0 deletions urwid/text_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
if typing.TYPE_CHECKING:
from typing_extensions import Literal


class TextLayout:
def supports_align_mode(self, align):
"""Return True if align is a supported align mode."""
Expand Down
6 changes: 3 additions & 3 deletions urwid/treetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from __future__ import annotations

import urwid
from urwid.wimp import SelectableIcon


class TreeWidgetError(RuntimeError):
Expand All @@ -42,9 +41,10 @@ class TreeWidgetError(RuntimeError):

class TreeWidget(urwid.WidgetWrap):
"""A widget representing something in a nested tree display."""

indent_cols = 3
unexpanded_icon = SelectableIcon('+', 0)
expanded_icon = SelectableIcon('-', 0)
unexpanded_icon = urwid.SelectableIcon("+", 0)
expanded_icon = urwid.SelectableIcon("-", 0)

def __init__(self, node):
self._node = node
Expand Down
Loading

0 comments on commit ff35832

Please sign in to comment.