Skip to content

Commit

Permalink
refactor: ran pyupgrade --py38-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Aug 12, 2022
1 parent 3e6ff83 commit 24fafe1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion aw_watcher_window/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ def get_current_window(strategy: str = None) -> Optional[dict]:
elif sys.platform in ["win32", "cygwin"]:
return get_current_window_windows()
else:
raise Exception("Unknown platform: {}".format(sys.platform))
raise Exception(f"Unknown platform: {sys.platform}")
2 changes: 1 addition & 1 deletion aw_watcher_window/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def main():
"aw-watcher-window", host=args.host, port=args.port, testing=args.testing
)

bucket_id = "{}_{}".format(client.client_name, client.client_hostname)
bucket_id = f"{client.client_name}_{client.client_hostname}"
event_type = "currentwindow"

client.create_bucket(bucket_id, event_type, queued=True)
Expand Down
6 changes: 3 additions & 3 deletions aw_watcher_window/xlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_window_name(window: Window) -> str:
try:
d = window.get_full_property(NET_WM_NAME, UTF8_STRING)
except Xlib.error.XError as e:
logger.warning("Unable to get window property NET_WM_NAME, got a {} exception from Xlib".format(type(e).__name__))
logger.warning(f"Unable to get window property NET_WM_NAME, got a {type(e).__name__} exception from Xlib")
# I strongly suspect window.get_wm_name() will also fail and we should return "unknown" right away.
# But I don't know, so I pass the thing on, for now.
d = None
Expand All @@ -69,7 +69,7 @@ def get_window_name(window: Window) -> str:
try:
return d.value.decode('utf8')
except UnicodeError:
logger.warning("Failed to decode one or more characters which will be skipped, bytes are: {}".format(d.value))
logger.warning(f"Failed to decode one or more characters which will be skipped, bytes are: {d.value}")
if isinstance(d.value, bytes):
return d.value.decode('utf8', 'ignore')
else:
Expand All @@ -92,7 +92,7 @@ def get_window_class(window: Window) -> str:
try:
window = window.query_tree().parent
except Xlib.error.XError as e:
logger.warning("Unable to get window query_tree().parent, got a {} exception from Xlib".format(type(e).__name__))
logger.warning(f"Unable to get window query_tree().parent, got a {type(e).__name__} exception from Xlib")
return "unknown"
if window:
return get_window_class(window)
Expand Down

0 comments on commit 24fafe1

Please sign in to comment.