From 798e992a1ceeadd6c17a333883864a71ef6e50d6 Mon Sep 17 00:00:00 2001 From: Jose Tiago Macara Coutinho Date: Wed, 19 Apr 2023 20:32:48 +0200 Subject: [PATCH] Apply isort through ruff --- examples/qt/label.py | 3 ++- examples/qt/widget.py | 5 +++-- examples/tk.py | 1 - examples/web/async.py | 4 +--- examples/web/common.py | 1 - examples/web/sync.py | 4 +--- examples/web_async.py | 1 - pyproject.toml | 2 +- tests/test_device.py | 8 ++++---- v4l2py/__init__.py | 6 +++--- v4l2py/device.py | 2 -- v4l2py/io.py | 2 +- 12 files changed, 16 insertions(+), 23 deletions(-) diff --git a/examples/qt/label.py b/examples/qt/label.py index 51e8d96..da2014b 100644 --- a/examples/qt/label.py +++ b/examples/qt/label.py @@ -1,5 +1,6 @@ import cv2 -from qtpy import QtWidgets, QtGui, QtCore +from qtpy import QtCore, QtGui, QtWidgets + from v4l2py import Device, VideoCapture diff --git a/examples/qt/widget.py b/examples/qt/widget.py index 23f536f..b11ff09 100644 --- a/examples/qt/widget.py +++ b/examples/qt/widget.py @@ -8,8 +8,9 @@ # run with: QT_API=pyqt6 python widget.py import cv2 -from qtpy import QtWidgets, QtGui, QtCore -from v4l2py import Device, VideoCapture, PixelFormat +from qtpy import QtCore, QtGui, QtWidgets + +from v4l2py import Device, PixelFormat, VideoCapture class QVideo(QtWidgets.QWidget): diff --git a/examples/tk.py b/examples/tk.py index 8729610..968efdf 100644 --- a/examples/tk.py +++ b/examples/tk.py @@ -12,7 +12,6 @@ from v4l2py import Device, VideoCapture - fmt = "%(threadName)-10s %(asctime)-15s %(levelname)-5s %(name)s: %(message)s" logging.basicConfig(level="INFO", format=fmt) diff --git a/examples/web/async.py b/examples/web/async.py index 275d6d8..cac586e 100644 --- a/examples/web/async.py +++ b/examples/web/async.py @@ -16,6 +16,7 @@ import logging from typing import Annotated +from common import BOUNDARY, BaseCamera, frame_to_image from fastapi import FastAPI, Form, Request from fastapi.responses import HTMLResponse, StreamingResponse from fastapi.staticfiles import StaticFiles @@ -23,9 +24,6 @@ from v4l2py.device import ControlType, Device, iter_video_capture_devices -from common import BaseCamera, frame_to_image, BOUNDARY - - logging.basicConfig( level="INFO", format="%(threadName)-10s %(asctime)-15s %(levelname)-5s %(name)s: %(message)s", diff --git a/examples/web/common.py b/examples/web/common.py index bb1ffea..9e87cfc 100644 --- a/examples/web/common.py +++ b/examples/web/common.py @@ -19,7 +19,6 @@ from v4l2py.device import Device, PixelFormat, VideoCapture - BOUNDARY = "frame" HEADER = ( "--{boundary}\r\nContent-Type: image/{type}\r\nContent-Length: {length}\r\n\r\n" diff --git a/examples/web/sync.py b/examples/web/sync.py index 912d5e0..bbe1601 100644 --- a/examples/web/sync.py +++ b/examples/web/sync.py @@ -21,13 +21,11 @@ import gevent.monkey import gevent.queue import gevent.time +from common import BOUNDARY, BaseCamera, frame_to_image from v4l2py.device import ControlType, Device, iter_video_capture_devices from v4l2py.io import GeventIO -from common import BaseCamera, frame_to_image, BOUNDARY - - gevent.monkey.patch_all() app = flask.Flask("basic-web-cam") diff --git a/examples/web_async.py b/examples/web_async.py index 175ba4f..e7420db 100644 --- a/examples/web_async.py +++ b/examples/web_async.py @@ -18,7 +18,6 @@ from v4l2py import Device, VideoCapture - PREFIX = b"--frame\r\nContent-Type: image/jpeg\r\n\r\n" SUFFIX = b"\r\n" INDEX = """\ diff --git a/pyproject.toml b/pyproject.toml index e8e12be..6d6f352 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,7 +75,7 @@ report = {skip_empty = true} branch = true [tool.ruff] -select = ["E", "F", "W", "C", "B", "B9"] +select = ["E", "F", "W", "C", "B", "B9", "I001"] ignore = ["B904", "B028", "C901", ] line-length = 120 target-version = "py37" diff --git a/tests/test_device.py b/tests/test_device.py index a6936d8..b3d45c2 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -7,12 +7,12 @@ from contextlib import ExitStack from errno import EINVAL from inspect import isgenerator +from math import isclose from pathlib import Path from random import randint from unittest import mock -from math import isclose -from ward import each, fixture, test, raises +from ward import each, fixture, raises, test try: import numpy @@ -21,10 +21,10 @@ from v4l2py import raw from v4l2py.device import ( + BufferType, Device, - VideoCapture, PixelFormat, - BufferType, + VideoCapture, device_number, iter_devices, iter_video_files, diff --git a/v4l2py/__init__.py b/v4l2py/__init__.py index b4f1449..b577225 100644 --- a/v4l2py/__init__.py +++ b/v4l2py/__init__.py @@ -9,13 +9,13 @@ from .device import ( Device, Frame, - VideoCapture, MemoryMap, PixelFormat, - iter_video_files, - iter_video_capture_files, + VideoCapture, iter_devices, iter_video_capture_devices, + iter_video_capture_files, + iter_video_files, ) from .io import IO, GeventIO diff --git a/v4l2py/device.py b/v4l2py/device.py index 8f6b26e..e76834e 100644 --- a/v4l2py/device.py +++ b/v4l2py/device.py @@ -17,13 +17,11 @@ import os import pathlib import typing - from io import IOBase from . import raw from .io import IO, fopen - log = logging.getLogger(__name__) log_ioctl = log.getChild("ioctl") log_mmap = log.getChild("mmap") diff --git a/v4l2py/io.py b/v4l2py/io.py index 27f2bdf..6d4fb29 100644 --- a/v4l2py/io.py +++ b/v4l2py/io.py @@ -4,8 +4,8 @@ # Copyright (c) 2021 Tiago Coutinho # Distributed under the GPLv3 license. See LICENSE for more info. -import os import functools +import os import select