From 6a74619be8b9de7e8096bae93078e871deaf0e4d Mon Sep 17 00:00:00 2001 From: Fabien Danieau Date: Wed, 26 Jun 2024 10:07:05 +0200 Subject: [PATCH] enhancement #42: add isort and update black, mypy --- .github/workflows/lint.yml | 35 ++++++++++++++----- setup.cfg | 15 ++++---- .../gstreamer_consumer/gstreamer_consumer.py | 6 ++-- src/gst_signalling/gst_consumer.py | 2 +- src/gst_signalling/gst_producer.py | 2 +- src/gst_signalling/utils.py | 2 +- 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index afdc1f4..4b31bfd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,22 +5,39 @@ on: [push] jobs: black: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - uses: psf/black@stable with: options: "--check --verbose" - version: "23.3.0" + version: "23.10.1" + + isort: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: 'pip' # caching pip dependencies + - name: Install dependencies + run: | + sudo apt install -y libgirepository1.0-dev + python -m pip install --upgrade pip + pip install .[dev] + - name : Check import order + run : isort . -c flake8: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.8 + - uses: actions/checkout@v4 + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.10" cache: 'pip' # caching pip dependencies - name: Install dependencies run: | @@ -32,12 +49,12 @@ jobs: # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # option --exit-zero can be added to this line to set these errors as warnings - flake8 . --count --max-complexity=10 --max-line-length=128 --statistics + flake8 . --count --statistics --config setup.cfg mypy: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v4 with: diff --git a/setup.cfg b/setup.cfg index 3014d7d..aea3ecc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,20 +16,19 @@ include_package_data = True package_dir= =src install_requires = - numpy + numpy>=1.24.0,<=1.26.4 pyee==11.0.1 - websockets==11.0.3 - PyGObject==3.42.2 + websockets<12.0.0 + PyGObject>=3.42.2, <=3.46.0 [options.packages.find] where=src [options.extras_require] -dev = black==23.3.0 - flake8==6.0.0 - pytest==7.3.1 - coverage==7.2.5 - mypy==1.0.0 +dev = black==23.10.1 + flake8==6.1.0 + mypy==1.6.1 + isort==5.12.0 pygobject-stubs==2.10.0 [options.entry_points] diff --git a/src/example/gstreamer_consumer/gstreamer_consumer.py b/src/example/gstreamer_consumer/gstreamer_consumer.py index 8c1f10b..08fb29f 100644 --- a/src/example/gstreamer_consumer/gstreamer_consumer.py +++ b/src/example/gstreamer_consumer/gstreamer_consumer.py @@ -1,10 +1,12 @@ import argparse +import logging import os import time -import logging -from gst_signalling import utils + import gi +from gst_signalling import utils + gi.require_version("Gst", "1.0") from gi.repository import Gst # noqa: E402 diff --git a/src/gst_signalling/gst_consumer.py b/src/gst_signalling/gst_consumer.py index d8cddfe..3d1f43f 100644 --- a/src/gst_signalling/gst_consumer.py +++ b/src/gst_signalling/gst_consumer.py @@ -43,7 +43,7 @@ def on_answer_created( assert promise.wait() == Gst.PromiseResult.REPLIED reply = promise.get_reply() # answer = reply["answer"] - answer = reply.get_value("answer") # type: ignore[union-attr] + answer = reply.get_value("answer") promise = Gst.Promise.new() webrtc.emit("set-local-description", answer, promise) promise.interrupt() # we don't care about the result, discard it diff --git a/src/gst_signalling/gst_producer.py b/src/gst_signalling/gst_producer.py index 07f9e31..e7907fe 100644 --- a/src/gst_signalling/gst_producer.py +++ b/src/gst_signalling/gst_producer.py @@ -26,7 +26,7 @@ def on_offer_created( self.logger.debug(f"on offer created {promise} {webrtc} {session_id}") assert promise.wait() == Gst.PromiseResult.REPLIED reply = promise.get_reply() - offer = reply.get_value("offer") # type: ignore[union-attr] + offer = reply.get_value("offer") promise = Gst.Promise.new() self.logger.info("Offer created, setting local description") diff --git a/src/gst_signalling/utils.py b/src/gst_signalling/utils.py index c62df7d..8768624 100644 --- a/src/gst_signalling/utils.py +++ b/src/gst_signalling/utils.py @@ -1,6 +1,6 @@ +import argparse import asyncio from typing import Dict -import argparse from .gst_signalling import GstSignalling