diff --git a/libqtile/extension/base.py b/libqtile/extension/base.py index 39ce1d443b..00f08b4779 100644 --- a/libqtile/extension/base.py +++ b/libqtile/extension/base.py @@ -95,13 +95,13 @@ class RunCommand(_Extension): `client `_. """ - defaults = [ + defaults: list[tuple[str, Any, str]] = [ # NOTE: Do not use a list as a default value, since it would be shared # among all the objects inheriting this class, and if one of them # modified it, all the other objects would see the modified list; # use a string or a tuple instead, which are immutable ("command", None, "the command to be launched (string or list with arguments)"), - ] # type: list[tuple[str, Any, str]] + ] def __init__(self, **config): _Extension.__init__(self, **config) diff --git a/libqtile/layout/base.py b/libqtile/layout/base.py index 8eabe9899b..5bda866fad 100644 --- a/libqtile/layout/base.py +++ b/libqtile/layout/base.py @@ -37,7 +37,7 @@ class Layout(CommandObject, configurable.Configurable, metaclass=ABCMeta): """This class defines the API that should be exposed by all layouts""" - defaults = [] # type: list[tuple[str, Any, str]] + defaults: list[tuple[str, Any, str]] = [] def __init__(self, **config): # name is a little odd; we can't resolve it until the class is defined diff --git a/libqtile/widget/base.py b/libqtile/widget/base.py index f40910e3ab..aeb868e69d 100644 --- a/libqtile/widget/base.py +++ b/libqtile/widget/base.py @@ -138,14 +138,14 @@ def open_calendar(): offsetx: int = 0 offsety: int = 0 - defaults = [ + defaults: list[tuple[str, Any, str]] = [ ("background", None, "Widget background color"), ( "mouse_callbacks", {}, "Dict of mouse button press callback functions. Accepts functions and ``lazy`` calls.", ), - ] # type: list[tuple[str, Any, str]] + ] def __init__(self, length, **config): """ diff --git a/libqtile/widget/battery.py b/libqtile/widget/battery.py index 6a0258ccda..e7f316ba98 100644 --- a/libqtile/widget/battery.py +++ b/libqtile/widget/battery.py @@ -192,7 +192,7 @@ class _LinuxBattery(_Battery, configurable.Configurable): ), ] - filenames = {} # type: dict + filenames: dict = {} BAT_DIR = "/sys/class/power_supply" @@ -451,12 +451,12 @@ class BatteryIcon(base._Widget): """Battery life indicator widget.""" orientations = base.ORIENTATION_HORIZONTAL - defaults = [ + defaults: list[tuple[str, Any, str]] = [ ("battery", 0, "Which battery should be monitored"), ("update_interval", 60, "Seconds between status updates"), ("theme_path", default_icon_path(), "Path of the icons"), ("scale", 1, "Scale factor relative to the bar height. " "Defaults to 1"), - ] # type: list[tuple[str, Any, str]] + ] icon_names = ( "battery-missing", @@ -481,12 +481,12 @@ def __init__(self, **config) -> None: base._Widget.__init__(self, length=bar.CALCULATED, **config) self.add_defaults(self.defaults) - self.scale = 1.0 / self.scale # type: float + self.scale: float = 1.0 / self.scale self.length_type = bar.STATIC self.length = 0 self.image_padding = 0 - self.surfaces = {} # type: dict[str, Img] + self.surfaces: dict[str, Img] = {} self.current_icon = "battery-missing" self._battery = self._load_battery(**config) diff --git a/libqtile/widget/generic_poll_text.py b/libqtile/widget/generic_poll_text.py index 97058eb711..3db76120a7 100644 --- a/libqtile/widget/generic_poll_text.py +++ b/libqtile/widget/generic_poll_text.py @@ -40,7 +40,7 @@ def poll(self): class GenPollUrl(base.ThreadPoolText): """A generic text widget that polls an url and parses it using parse function""" - defaults = [ + defaults: list[tuple[str, Any, str]] = [ ("url", None, "Url"), ("data", None, "Post Data"), ("parse", None, "Parse Function"), @@ -48,7 +48,7 @@ class GenPollUrl(base.ThreadPoolText): ("user_agent", "Qtile", "Set the user agent"), ("headers", {}, "Extra Headers"), ("xml", False, "Is XML?"), - ] # type: list[tuple[str, Any, str]] + ] def __init__(self, **config): base.ThreadPoolText.__init__(self, "", **config) diff --git a/libqtile/widget/groupbox.py b/libqtile/widget/groupbox.py index 400c9cd815..71e7040884 100644 --- a/libqtile/widget/groupbox.py +++ b/libqtile/widget/groupbox.py @@ -39,10 +39,10 @@ class _GroupBase(base._TextBox, base.PaddingMixin, base.MarginMixin): - defaults = [ + defaults: list[tuple[str, Any, str]] = [ ("borderwidth", 3, "Current group border width"), ("center_aligned", True, "center-aligned group box"), - ] # type: list[tuple[str, Any, str]] + ] def __init__(self, **config): base._TextBox.__init__(self, **config) diff --git a/libqtile/widget/open_weather.py b/libqtile/widget/open_weather.py index c6e7b63a8e..125bf72335 100644 --- a/libqtile/widget/open_weather.py +++ b/libqtile/widget/open_weather.py @@ -188,7 +188,7 @@ class OpenWeather(GenPollUrl): "50n": "🌫", } - defaults = [ + defaults: list[tuple[str, Any, str]] = [ # One of (cityid, location, zip, coordinates) must be set. ( "app_key", @@ -255,7 +255,7 @@ class OpenWeather(GenPollUrl): dict(), "Dictionary of weather symbols. Can be used to override default symbols.", ), - ] # type: list[tuple[str, Any, str]] + ] def __init__(self, **config): GenPollUrl.__init__(self, **config) diff --git a/libqtile/widget/textbox.py b/libqtile/widget/textbox.py index 7cd54f4fee..f65f1be281 100644 --- a/libqtile/widget/textbox.py +++ b/libqtile/widget/textbox.py @@ -33,13 +33,13 @@ class TextBox(base._TextBox): """A flexible textbox that can be updated from bound keys, scripts, and qshell.""" - defaults = [ + defaults: list[tuple[str, Any, str]] = [ ("font", "sans", "Text font"), ("fontsize", None, "Font pixel size. Calculated if None."), ("fontshadow", None, "font shadow color, default is None(no shadow)"), ("padding", None, "Padding left and right. Calculated if None."), ("foreground", "#ffffff", "Foreground colour."), - ] # type: list[tuple[str, Any, str]] + ] def __init__(self, text=" ", width=bar.CALCULATED, **config): base._TextBox.__init__(self, text=text, width=width, **config) diff --git a/libqtile/widget/widgetbox.py b/libqtile/widget/widgetbox.py index 1b7cac1a89..a5e88e079b 100644 --- a/libqtile/widget/widgetbox.py +++ b/libqtile/widget/widgetbox.py @@ -55,7 +55,7 @@ class WidgetBox(base._Widget): """ orientations = base.ORIENTATION_HORIZONTAL - defaults = [ + defaults: list[tuple[str, Any, str]] = [ ("font", "sans", "Text font"), ("fontsize", None, "Font pixel size. Calculated if None."), ("fontshadow", None, "font shadow color, default is None(no shadow)"), @@ -68,7 +68,7 @@ class WidgetBox(base._Widget): ("text_closed", "[<]", "Text when box is closed"), ("text_open", "[>]", "Text when box is open"), ("widgets", list(), "A list of widgets to include in the box"), - ] # type: list[tuple[str, Any, str]] + ] def __init__(self, _widgets: list[base._Widget] | None = None, **config): base._Widget.__init__(self, bar.CALCULATED, **config) diff --git a/libqtile/widget/window_count.py b/libqtile/widget/window_count.py index 35d542fa94..5db97e4a3d 100644 --- a/libqtile/widget/window_count.py +++ b/libqtile/widget/window_count.py @@ -33,7 +33,7 @@ class WindowCount(base._TextBox): current group of the screen on which the widget is. """ - defaults = [ + defaults: list[tuple[str, Any, str]] = [ ("font", "sans", "Text font"), ("fontsize", None, "Font pixel size. Calculated if None."), ("fontshadow", None, "font shadow color, default is None(no shadow)"), @@ -41,7 +41,7 @@ class WindowCount(base._TextBox): ("foreground", "#ffffff", "Foreground colour."), ("text_format", "{num}", "Format for message"), ("show_zero", False, "Show window count when no windows"), - ] # type: list[tuple[str, Any, str]] + ] def __init__(self, width=bar.CALCULATED, **config): base._TextBox.__init__(self, width=width, **config)