From c12a55612fa7645bc1b46b4b67a8a40c69e0e638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Lain=C3=A9?= Date: Fri, 12 Jan 2024 14:37:17 +0100 Subject: [PATCH] Reformat code using ruff --- .github/workflows/tests.yml | 6 ++-- .gitignore | 11 ++++++ docs/conf.py | 71 ++++++++++++++++++------------------- scripts/fetch-vendor.py | 2 +- setup.py | 2 +- tests/test_session.py | 11 +++--- 6 files changed, 57 insertions(+), 46 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 587f4ad..b769ac0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,11 +12,11 @@ jobs: with: python-version: 3.8 - name: Install packages - run: pip install black ruff + run: pip install ruff - name: Run linters run: | - ruff src tests - black --check --diff src tests + ruff . + ruff format --check --diff . test: runs-on: ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index 2a3f49b..3801188 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,18 @@ *.so .coverage .eggs +.idea +.mypy_cache .vscode /build /dist /docs/_build + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ diff --git a/docs/conf.py b/docs/conf.py index 78c32a9..7641979 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,12 +13,13 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os, sys +import os +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath("..")) # -- General configuration ------------------------------------------------ @@ -29,33 +30,33 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.autodoc'] +extensions = ["sphinx.ext.autodoc"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'pylibsrtp' -copyright = u'2018, Jeremy Lainé' -author = u'Jeremy Lainé' +project = "pylibsrtp" +copyright = "2018, Jeremy Lainé" +author = "Jeremy Lainé" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '' +version = "" # The full version, including alpha/beta/rc tags. -release = '' +release = "" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -67,10 +68,10 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -81,22 +82,22 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = "alabaster" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # html_theme_options = { - 'github_button': True, - 'github_user': 'aiortc', - 'github_repo': 'pylibsrtp', + "github_button": True, + "github_user": "aiortc", + "github_repo": "pylibsrtp", } # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # Custom sidebar templates, must be a dictionary that maps document names # to template names. @@ -104,9 +105,9 @@ # This is required for the alabaster theme # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars html_sidebars = { - '**': [ - 'relations.html', # needs 'show_related': True theme option to display - 'searchbox.html', + "**": [ + "relations.html", # needs 'show_related': True theme option to display + "searchbox.html", ] } @@ -114,7 +115,7 @@ # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'pylibsrtpdoc' +htmlhelp_basename = "pylibsrtpdoc" # -- Options for LaTeX output --------------------------------------------- @@ -123,15 +124,12 @@ # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. # # 'preamble': '', - # Latex figure (float) alignment # # 'figure_align': 'htbp', @@ -141,8 +139,7 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'pylibsrtp.tex', 'pylibsrtp Documentation', - u'Jeremy Lainé', 'manual'), + (master_doc, "pylibsrtp.tex", "pylibsrtp Documentation", "Jeremy Lainé", "manual"), ] @@ -150,10 +147,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'pylibsrtp', 'pylibsrtp Documentation', - [author], 1) -] +man_pages = [(master_doc, "pylibsrtp", "pylibsrtp Documentation", [author], 1)] # -- Options for Texinfo output ------------------------------------------- @@ -162,10 +156,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'pylibsrtp', 'pylibsrtp Documentation', - author, 'pylibsrtp', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "pylibsrtp", + "pylibsrtp Documentation", + author, + "pylibsrtp", + "One line description of project.", + "Miscellaneous", + ), ] - - - diff --git a/scripts/fetch-vendor.py b/scripts/fetch-vendor.py index 3ea3a0c..fe7b91c 100644 --- a/scripts/fetch-vendor.py +++ b/scripts/fetch-vendor.py @@ -1,6 +1,6 @@ import argparse -import logging import json +import logging import os import platform import shutil diff --git a/setup.py b/setup.py index 65e0270..bd1ef2e 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,6 @@ def get_tag(self): setuptools.setup( - cffi_modules = ["src/_cffi_src/build_srtp.py:ffibuilder"], + cffi_modules=["src/_cffi_src/build_srtp.py:ffibuilder"], cmdclass={"bdist_wheel": bdist_wheel_abi3}, ) diff --git a/tests/test_session.py b/tests/test_session.py index 55fa460..cf0cf7a 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -5,10 +5,13 @@ from pylibsrtp import Error, Policy, Session RTP = ( - b"\x80\x08\x00\x00" # version, packet type, sequence number - b"\x00\x00\x00\x00" # timestamp - b"\x00\x00\x30\x39" # ssrc: 12345 -) + (b"\xd4" * 160) + ( + b"\x80\x08\x00\x00" # version, packet type, sequence number + b"\x00\x00\x00\x00" # timestamp + b"\x00\x00\x30\x39" # ssrc: 12345 + ) + + (b"\xd4" * 160) +) RTCP = ( b"\x80\xc8\x00\x06\xf3\xcb\x20\x01\x83\xab\x03\xa1\xeb\x02\x0b\x3a" b"\x00\x00\x94\x20\x00\x00\x00\x9e\x00\x00\x9b\x88"