ci: Add and configure isort, and make it happy

This commit is contained in:
Gergely Polonkai 2023-11-01 07:16:17 +01:00
parent 9bf9352bfc
commit ebcc94516c
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
12 changed files with 39 additions and 31 deletions

View File

@ -30,3 +30,10 @@ repos:
language: system
types: [python]
require_serial: true
- id: isort
name: isort
args: ["--check", "--diff"]
entry: poetry run isort
language: system
require_serial: true
types_or: [python, pyi]

View File

@ -1,15 +1,15 @@
"""Example SSB Client"""
from asyncio import ensure_future, gather, get_event_loop
import base64
import hashlib
import logging
import struct
import time
from asyncio import get_event_loop, gather, ensure_future
from colorlog import ColoredFormatter
from secret_handshake.network import SHSClient
from ssb.muxrpc import MuxRPCAPI, MuxRPCAPIException
from ssb.packet_stream import PacketStream, PSMessageType
from ssb.util import load_ssb_secret

View File

@ -1,13 +1,13 @@
"""Test SSB server"""
import logging
from asyncio import get_event_loop
import logging
from colorlog import ColoredFormatter
from secret_handshake import SHSServer
from ssb.packet_stream import PacketStream
from ssb.muxrpc import MuxRPCAPI
from ssb.packet_stream import PacketStream
from ssb.util import load_ssb_secret
api = MuxRPCAPI()

18
poetry.lock generated
View File

@ -526,20 +526,20 @@ files = [
[[package]]
name = "isort"
version = "4.3.21"
version = "5.12.0"
description = "A Python utility / library to sort Python imports."
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
python-versions = ">=3.8.0"
files = [
{file = "isort-4.3.21-py2.py3-none-any.whl", hash = "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd"},
{file = "isort-4.3.21.tar.gz", hash = "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1"},
{file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"},
{file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"},
]
[package.extras]
pipfile = ["pipreqs", "requirementslib"]
pyproject = ["toml"]
requirements = ["pip-api", "pipreqs"]
xdg-home = ["appdirs (>=1.4.0)"]
colors = ["colorama (>=0.4.3)"]
pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"]
plugins = ["setuptools"]
requirements-deprecated-finder = ["pip-api", "pipreqs"]
[[package]]
name = "jinja2"
@ -1269,4 +1269,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p
[metadata]
lock-version = "2.0"
python-versions = "^3.9"
content-hash = "63b3d6f54c99a6722a3d0d5cf9eac68bdb5ef0ea7c58957dd76494529870186c"
content-hash = "4c675f7bcb417a7a7d8cf065f804c796ccc476edffc79e99dbed152ff94c6d58"

View File

@ -17,7 +17,7 @@ colorlog = "^6.7.0"
[tool.poetry.group.dev.dependencies]
check-manifest = "^0.39"
coverage = "^7.3.2"
isort = "^4.3.20"
isort = "^5.12.0"
pep257 = "^0.7.0"
pytest = "^7.4.3"
pytest-asyncio = "^0.21.1"
@ -42,6 +42,11 @@ skip_covered = true
fail_under = 70
omit = ["examples/*"]
[tool.isort]
force_sort_within_sections = true
line_length = 120
profile = "black"
[tool.pylint.format]
max-line-length = 120

View File

@ -1,5 +1,5 @@
"""Feed related functionality"""
from .models import Feed, LocalFeed, Message, LocalMessage, NoPrivateKeyException
from .models import Feed, LocalFeed, LocalMessage, Message, NoPrivateKeyException
__all__ = ("Feed", "LocalFeed", "Message", "LocalMessage", "NoPrivateKeyException")

View File

@ -1,15 +1,14 @@
"""Feed models"""
import datetime
from base64 import b64encode
from collections import namedtuple, OrderedDict
from collections import OrderedDict, namedtuple
import datetime
from hashlib import sha256
from simplejson import dumps, loads
from ssb.util import tag
OrderedMsg = namedtuple("OrderedMsg", ("previous", "author", "sequence", "timestamp", "hash", "content"))

View File

@ -1,15 +1,14 @@
"""Packet streams"""
import logging
import struct
from asyncio import Event, Queue
from enum import Enum
from time import time
import logging
from math import ceil
import struct
from time import time
import simplejson
logger = logging.getLogger("packet_stream")

View File

@ -3,8 +3,8 @@
from base64 import b64decode, b64encode
import os
import yaml
from nacl.signing import SigningKey
import yaml
class ConfigException(Exception):

View File

@ -3,11 +3,10 @@
from base64 import b64decode
from collections import OrderedDict
import pytest
from nacl.signing import SigningKey, VerifyKey
import pytest
from ssb.feed import LocalMessage, LocalFeed, Feed, Message, NoPrivateKeyException
from ssb.feed import Feed, LocalFeed, LocalMessage, Message, NoPrivateKeyException
SERIALIZED_M1 = b"""{
"previous": null,

View File

@ -1,11 +1,11 @@
"""Tests for the packet stream"""
from asyncio import Event, ensure_future, gather
import json
from asyncio import ensure_future, gather, Event
import pytest
from secret_handshake.network import SHSDuplexStream
from ssb.packet_stream import PacketStream, PSMessageType

View File

@ -5,8 +5,7 @@ from unittest.mock import mock_open, patch
import pytest
from ssb.util import load_ssb_secret, ConfigException
from ssb.util import ConfigException, load_ssb_secret
CONFIG_FILE = """
## Comments should be supported too