Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black autoformatter #2144

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check --verbose --line-length 120 -t py38 -t py39 -t py310 -t py311 -t py312"
src: "./blueman/"
18 changes: 0 additions & 18 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,6 @@ jobs:
- run: meson --warnlevel 3 --buildtype debug -Druntime_deps_check=false builddebug
- run: ninja -v -C builddebug/

flake8:
strategy:
fail-fast: false
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12-rc"
runs-on: ubuntu-latest
container:
image: python:${{ matrix.python }}
steps:
- uses: actions/checkout@v2
- run: python3 -m pip install --user flake8
- run: python3 -m flake8

mypy:
strategy:
fail-fast: false
Expand Down
8 changes: 4 additions & 4 deletions apps/blueman-adapters.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import gettext


# support running uninstalled
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if 'BLUEMAN_SOURCE' in os.environ:
sys.path = [_dirname, os.path.join(_dirname, 'module', '.libs')] + sys.path
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if "BLUEMAN_SOURCE" in os.environ:
sys.path = [_dirname, os.path.join(_dirname, "module", ".libs")] + sys.path
os.environ["GSETTINGS_SCHEMA_DIR"] = os.path.join(_dirname, "data")

gettext.textdomain("@GETTEXT_PACKAGE@")
Expand All @@ -17,7 +17,7 @@ from blueman.Functions import create_parser, create_logger, set_proc_title
from blueman.main.Adapter import BluemanAdapters


if __name__ == '__main__':
if __name__ == "__main__":
parser = parser = create_parser()
parser.add_argument("--socket-id", dest="socket_id", action="store", type=int, metavar="ID")
parser.add_argument("adapter", nargs="?", metavar="ADAPTER NAME")
Expand Down
6 changes: 3 additions & 3 deletions apps/blueman-applet.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import gettext

# support running uninstalled
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if 'BLUEMAN_SOURCE' in os.environ:
sys.path = [_dirname, os.path.join(_dirname, 'module', '.libs')] + sys.path
if "BLUEMAN_SOURCE" in os.environ:
sys.path = [_dirname, os.path.join(_dirname, "module", ".libs")] + sys.path
os.environ["GSETTINGS_SCHEMA_DIR"] = os.path.join(_dirname, "data")

gettext.textdomain("@GETTEXT_PACKAGE@")
Expand All @@ -16,7 +16,7 @@ from blueman.Functions import create_logger, create_parser, set_proc_title
from blueman.main.Applet import BluemanApplet


if __name__ == '__main__':
if __name__ == "__main__":
parser = create_parser()
args = parser.parse_args()

Expand Down
8 changes: 4 additions & 4 deletions apps/blueman-manager.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import logging
import gettext

# support running uninstalled
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if 'BLUEMAN_SOURCE' in os.environ:
sys.path = [_dirname, os.path.join(_dirname, 'module', '.libs')] + sys.path
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if "BLUEMAN_SOURCE" in os.environ:
sys.path = [_dirname, os.path.join(_dirname, "module", ".libs")] + sys.path
os.environ["GSETTINGS_SCHEMA_DIR"] = os.path.join(_dirname, "data")

gettext.textdomain("@GETTEXT_PACKAGE@")
Expand All @@ -16,7 +16,7 @@ from blueman.main.Manager import Blueman
from blueman.Functions import set_proc_title, create_parser, create_logger


if __name__ == '__main__':
if __name__ == "__main__":
parser = create_parser()
args = parser.parse_args()

Expand Down
9 changes: 5 additions & 4 deletions apps/blueman-mechanism.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import logging
from blueman.main.MechanismApplication import MechanismApplication

# support running uninstalled
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if 'BLUEMAN_SOURCE' in os.environ:
sys.path = [_dirname, os.path.join(_dirname, 'module', '.libs')] + sys.path
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if "BLUEMAN_SOURCE" in os.environ:
sys.path = [_dirname, os.path.join(_dirname, "module", ".libs")] + sys.path
os.environ["GSETTINGS_SCHEMA_DIR"] = os.path.join(_dirname, "data")

from blueman.Functions import set_proc_title, create_logger, create_parser
Expand All @@ -18,10 +18,11 @@ class StreamToLogger:
"""
Fake file-like stream object that redirects writes to a logger instance.
"""

def __init__(self, logger, log_level=logging.INFO):
self.logger = logger
self.log_level = log_level
self.linebuf = ''
self.linebuf = ""

def write(self, buf):
for line in buf.rstrip().splitlines():
Expand Down
3 changes: 2 additions & 1 deletion apps/blueman-rfcomm-watcher.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ def on_file_changed(monitor, file, other_file, event_type):
if event_type == Gio.FileMonitorEvent.DELETED:
loop.quit()


parser = argparse.ArgumentParser()
parser.add_argument("path", action="store")
args = parser.parse_args()

mon = Gio.File.new_for_path(args.path).monitor_file(Gio.FileMonitorFlags.NONE)
mon.connect('changed', on_file_changed)
mon.connect("changed", on_file_changed)

fd = open_rfcomm(args.path, os.O_RDONLY)

Expand Down
41 changes: 29 additions & 12 deletions apps/blueman-sendto.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import logging
import gettext

import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gio

# support running uninstalled
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if 'BLUEMAN_SOURCE' in os.environ:
sys.path = [_dirname, os.path.join(_dirname, 'module', '.libs')] + sys.path
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if "BLUEMAN_SOURCE" in os.environ:
sys.path = [_dirname, os.path.join(_dirname, "module", ".libs")] + sys.path
os.environ["GSETTINGS_SCHEMA_DIR"] = os.path.join(_dirname, "data")

_ = gettext.gettext
Expand All @@ -25,7 +26,7 @@ from blueman.Functions import (
set_proc_title,
create_parser,
create_logger,
bmexit
bmexit,
)
from blueman.main.Sendto import Sender
from blueman.bluez.Manager import Manager
Expand Down Expand Up @@ -73,9 +74,11 @@ class SendTo:
self.adapter_path = adapter.get_object_path()

if parsed_args.delete:

def delete_files():
for file in self.files:
os.unlink(file)

atexit.register(delete_files)

if parsed_args.device is None:
Expand Down Expand Up @@ -106,7 +109,9 @@ class SendTo:

@staticmethod
def select_files():
d = Gtk.FileChooserDialog(title=_("Select files to send"), icon_name='blueman-send-symbolic', select_multiple=True)
d = Gtk.FileChooserDialog(
title=_("Select files to send"), icon_name="blueman-send-symbolic", select_multiple=True
)
d.add_buttons(_("_Cancel"), Gtk.ResponseType.REJECT, _("_OK"), Gtk.ResponseType.ACCEPT)
resp = d.run()

Expand All @@ -133,15 +138,27 @@ class SendTo:
return False


if __name__ == '__main__':
if __name__ == "__main__":
parser = create_parser(syslog=True)
parser.add_argument("-d", "--device", "--dest", dest="device", action="store",
help=_("Send files to this device"), metavar="ADDRESS")
parser.add_argument("-s", "--source", dest="source", action="store",
help=_("Source adapter. Takes address or adapter's name eg. hci0"), metavar="PATTERN")
parser.add_argument(
"-d",
"--device",
"--dest",
dest="device",
action="store",
help=_("Send files to this device"),
metavar="ADDRESS",
)
parser.add_argument(
"-s",
"--source",
dest="source",
action="store",
help=_("Source adapter. Takes address or adapter's name eg. hci0"),
metavar="PATTERN",
)
parser.add_argument("-u", "--delete", dest="delete", action="store_true", help=_("Delete files on exit"))
parser.add_argument("files", nargs="*", metavar="FILE",
help=_("Files to be send to the bluetooth device"))
parser.add_argument("files", nargs="*", metavar="FILE", help=_("Files to be send to the bluetooth device"))

args = parser.parse_args()

Expand Down
8 changes: 4 additions & 4 deletions apps/blueman-services.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import signal
import gettext

# support running uninstalled
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if 'BLUEMAN_SOURCE' in os.environ:
sys.path = [_dirname, os.path.join(_dirname, 'module', '.libs')] + sys.path
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if "BLUEMAN_SOURCE" in os.environ:
sys.path = [_dirname, os.path.join(_dirname, "module", ".libs")] + sys.path
os.environ["GSETTINGS_SCHEMA_DIR"] = os.path.join(_dirname, "data")

_ = gettext.gettext
Expand All @@ -19,7 +19,7 @@ from blueman.Functions import set_proc_title, setup_icon_path, create_logger, cr
from blueman.main.Services import BluemanServices


if __name__ == '__main__':
if __name__ == "__main__":
parser = create_parser()
args = parser.parse_args()

Expand Down
4 changes: 2 additions & 2 deletions apps/blueman-tray.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import gettext

# support running uninstalled
_dirname = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if 'BLUEMAN_SOURCE' in os.environ:
if "BLUEMAN_SOURCE" in os.environ:
sys.path.insert(0, _dirname)

gettext.textdomain("@GETTEXT_PACKAGE@")
Expand All @@ -15,7 +15,7 @@ from blueman.Functions import set_proc_title, create_parser, create_logger
from blueman.main.Tray import BluemanTray


if __name__ == '__main__':
if __name__ == "__main__":
parser = create_parser()
args = parser.parse_args()

Expand Down
Loading
Loading