Skip to content

Commit

Permalink
*: fix python2 type annotations
Browse files Browse the repository at this point in the history
pyflakes 3.0.0 drops support for the comment style annotations, in favor of
the actual syntactic version of type annotations.

This gets everything to pass flake8 again, but there are still many
instances of " # type" that we should fix.

PyCQA/pyflakes#747 (comment)

Signed-off-by: Tycho Andersen <[email protected]>
  • Loading branch information
tych0 committed Nov 29, 2022
1 parent 735c515 commit 5cfbe21
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions libqtile/extension/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ class RunCommand(_Extension):
`client <http://docs.qtile.org/en/latest/manual/commands/scripting.html>`_.
"""

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)
Expand Down
2 changes: 1 addition & 1 deletion libqtile/layout/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libqtile/widget/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
10 changes: 5 additions & 5 deletions libqtile/widget/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class _LinuxBattery(_Battery, configurable.Configurable):
),
]

filenames = {} # type: dict
filenames: dict = {}

BAT_DIR = "/sys/class/power_supply"

Expand Down Expand Up @@ -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",
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions libqtile/widget/generic_poll_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ 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"),
("json", True, "Is Json?"),
("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)
Expand Down
4 changes: 2 additions & 2 deletions libqtile/widget/groupbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions libqtile/widget/open_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions libqtile/widget/textbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions libqtile/widget/widgetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"),
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions libqtile/widget/window_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ 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)"),
("padding", None, "Padding left and right. Calculated if None."),
("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)
Expand Down

0 comments on commit 5cfbe21

Please sign in to comment.