Skip to content

Commit

Permalink
Run isort over the code
Browse files Browse the repository at this point in the history
Also add it to pre-commit config.
  • Loading branch information
bmerry committed Aug 2, 2023
1 parent bfb75bf commit f5d0033
Show file tree
Hide file tree
Showing 34 changed files with 160 additions and 94 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand Down
10 changes: 5 additions & 5 deletions examples/recv_chunk_group_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
# ringbuffers. To test it, run
# spead2_send localhost:8888 localhost:8889 --heaps 1000 --heap-size 65536 --rate 10

from spead2.numba import intp_to_voidptr
import spead2.recv
from spead2.recv.numba import chunk_place_data

import numba
from numba import types
import numpy as np
import scipy
from numba import types

import spead2.recv
from spead2.numba import intp_to_voidptr
from spead2.recv.numba import chunk_place_data

HEAP_PAYLOAD_SIZE = 65536
HEAPS_PER_CHUNK = 64
Expand Down
10 changes: 5 additions & 5 deletions examples/recv_chunk_ring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
# test it, run
# spead2_send localhost:8888 --heaps 1000 --heap-size 65536 --rate 10

from spead2.numba import intp_to_voidptr
import spead2.recv
from spead2.recv.numba import chunk_place_data

import numba
from numba import types
import numpy as np
import scipy
from numba import types

import spead2.recv
from spead2.numba import intp_to_voidptr
from spead2.recv.numba import chunk_place_data

HEAP_PAYLOAD_SIZE = 65536
HEAPS_PER_CHUNK = 64
Expand Down
3 changes: 2 additions & 1 deletion examples/test_recv.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import logging

import spead2
import spead2.recv
import logging

logging.basicConfig(level=logging.INFO)

Expand Down
6 changes: 4 additions & 2 deletions examples/test_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import spead2
import spead2.send
import logging

import numpy as np

import spead2
import spead2.send

logging.basicConfig(level=logging.INFO)

thread_pool = spead2.ThreadPool()
Expand Down
3 changes: 1 addition & 2 deletions examples/test_send_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import logging
import asyncio
import logging

import numpy as np

import spead2
import spead2.send
import spead2.send.asyncio


logging.basicConfig(level=logging.INFO)

thread_pool = spead2.ThreadPool()
Expand Down
3 changes: 1 addition & 2 deletions gen/gen_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@

import jinja2
from pycparser import c_ast
from pycparser.c_parser import CParser
from pycparser.c_generator import CGenerator

from pycparser.c_parser import CParser

# The typedefs are arbitrary and just used to allow pycparser to parse the
# code. Note that some functions in infiniband/verbs.h are implemented as
Expand Down
2 changes: 1 addition & 1 deletion gen/get_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import argparse
import re
import sys
from packaging.version import Version

from packaging.version import Version

parser = argparse.ArgumentParser()
parser.add_argument('mode', choices=('major', 'minor', 'patch', 'full'))
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ archs = ["x86_64"]
CC = "ccache gcc"
CFLAGS = "-flto"
LDFLAGS = "-flto"

[tool.isort]
profile = "black"
combine_as_imports = true
line_length = 100
py_version = 38
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import os.path
import subprocess

from setuptools import setup
from pybind11.setup_helpers import ParallelCompile, Pybind11Extension, build_ext
from setuptools import setup


class BuildExt(build_ext):
Expand Down
54 changes: 31 additions & 23 deletions src/spead2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,53 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numbers as _numbers
import logging
import numbers as _numbers
import struct

import numpy as _np

import spead2._spead2
from spead2._spead2 import ( # noqa: F401
Flavour, ThreadPool, Stopped, Empty, Full,
MemoryAllocator, MmapAllocator, MemoryPool, InprocQueue,
from spead2._spead2 import ( # noqa: F401
BUG_COMPAT_DESCRIPTOR_WIDTHS,
BUG_COMPAT_PYSPEAD_0_5_2,
BUG_COMPAT_SHAPE_BIT_1,
BUG_COMPAT_SWAP_ENDIAN,
BUG_COMPAT_PYSPEAD_0_5_2,
NULL_ID,
HEAP_CNT_ID,
HEAP_LENGTH_ID,
PAYLOAD_OFFSET_ID,
PAYLOAD_LENGTH_ID,
DESCRIPTOR_ID,
STREAM_CTRL_ID,
DESCRIPTOR_NAME_ID,
CTRL_DESCRIPTOR_REISSUE,
CTRL_DESCRIPTOR_UPDATE,
CTRL_STREAM_START,
CTRL_STREAM_STOP,
DESCRIPTOR_DESCRIPTION_ID,
DESCRIPTOR_SHAPE_ID,
DESCRIPTOR_DTYPE_ID,
DESCRIPTOR_FORMAT_ID,
DESCRIPTOR_ID,
DESCRIPTOR_ID_ID,
DESCRIPTOR_DTYPE_ID,
CTRL_STREAM_START,
CTRL_DESCRIPTOR_REISSUE,
CTRL_STREAM_STOP,
CTRL_DESCRIPTOR_UPDATE,
DESCRIPTOR_NAME_ID,
DESCRIPTOR_SHAPE_ID,
HEAP_CNT_ID,
HEAP_LENGTH_ID,
MEMCPY_NONTEMPORAL,
MEMCPY_STD,
MEMCPY_NONTEMPORAL)
NULL_ID,
PAYLOAD_LENGTH_ID,
PAYLOAD_OFFSET_ID,
STREAM_CTRL_ID,
Empty,
Flavour,
Full,
InprocQueue,
MemoryAllocator,
MemoryPool,
MmapAllocator,
Stopped,
ThreadPool,
)

try:
from spead2._spead2 import IbvContext # noqa: F401
from spead2._spead2 import IbvContext # noqa: F401
except ImportError:
pass
from spead2._version import __version__ # noqa: F401

from spead2._version import __version__ # noqa: F401

_logger = logging.getLogger(__name__)
_UNRESERVED_ID = 0x1000 #: First ID that can be auto-allocated
Expand Down
16 changes: 14 additions & 2 deletions src/spead2/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from typing import (List, Sequence, Optional, Tuple, Any, Union,
Dict, KeysView, ValuesView, Text, overload)
from typing import (
Any,
Dict,
KeysView,
List,
Optional,
Sequence,
Text,
Tuple,
Union,
ValuesView,
overload,
)

import numpy as np

try:
from numpy.typing import DTypeLike as _DTypeLike
except ImportError:
Expand Down
10 changes: 6 additions & 4 deletions src/spead2/recv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@

from collections.abc import Sequence as _Sequence

from spead2._spead2.recv import ( # noqa: F401
from spead2._spead2.recv import ( # noqa: F401
Chunk,
ChunkRingbuffer,
ChunkRingPair,
ChunkRingStream,
ChunkRingbuffer,
ChunkStreamConfig,
ChunkStreamGroupConfig,
ChunkStreamGroupMember,
Expand All @@ -73,9 +73,11 @@
StreamStatConfig,
StreamStats,
)
from . import stream_stat_indices # noqa: F401

from . import stream_stat_indices # noqa: F401

try:
from spead2._spead2.recv import UdpIbvConfig # noqa: F401
from spead2._spead2.recv import UdpIbvConfig # noqa: F401
except ImportError:
pass

Expand Down
14 changes: 13 additions & 1 deletion src/spead2/recv/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@
import collections.abc
import enum
import socket
from typing import Iterator, Iterable, Any, List, Tuple, Sequence, Union, Text, Optional, ClassVar, overload
from typing import (
Any,
ClassVar,
Iterable,
Iterator,
List,
Optional,
Sequence,
Text,
Tuple,
Union,
overload,
)

import spead2
from spead2 import _EndpointList
Expand Down
2 changes: 1 addition & 1 deletion src/spead2/recv/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"""
Integration between spead2.recv and asyncio
"""
import asyncio
import collections
import functools
import asyncio

import spead2.recv

Expand Down
1 change: 0 additions & 1 deletion src/spead2/recv/numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from numba import types


try:
_size_t = types.size_t
except AttributeError:
Expand Down
1 change: 0 additions & 1 deletion src/spead2/recv/numba.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@

import numba.types


chunk_place_data: numba.types.Record
20 changes: 16 additions & 4 deletions src/spead2/send/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@
import weakref

import spead2 as _spead2
from spead2._spead2.send import ( # noqa: F401
RateMethod, StreamConfig, GroupMode, Heap, HeapReference, HeapReferenceList,
PacketGenerator, Stream, BytesStream, UdpStream, TcpStream, InprocStream)
from spead2._spead2.send import ( # noqa: F401
BytesStream,
GroupMode,
Heap,
HeapReference,
HeapReferenceList,
InprocStream,
PacketGenerator,
RateMethod,
Stream,
StreamConfig,
TcpStream,
UdpStream,
)

try:
from spead2._spead2.send import UdpIbvStream, UdpIbvConfig # noqa: F401
from spead2._spead2.send import UdpIbvConfig, UdpIbvStream # noqa: F401
except ImportError:
pass

Expand Down
15 changes: 12 additions & 3 deletions src/spead2/send/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from typing import (
Text, Union, List, Tuple, Iterator, Iterable, Optional, Sequence, ClassVar, overload
)
import enum
import socket
from typing import (
ClassVar,
Iterable,
Iterator,
List,
Optional,
Sequence,
Text,
Tuple,
Union,
overload,
)

import spead2
from spead2 import _EndpointList
Expand Down
9 changes: 5 additions & 4 deletions src/spead2/send/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

import asyncio


from spead2._spead2.send import UdpStreamAsyncio as _UdpStreamAsyncio
from spead2._spead2.send import TcpStreamAsyncio as _TcpStreamAsyncio
from spead2._spead2.send import InprocStreamAsyncio as _InprocStreamAsyncio
from spead2._spead2.send import (
InprocStreamAsyncio as _InprocStreamAsyncio,
TcpStreamAsyncio as _TcpStreamAsyncio,
UdpStreamAsyncio as _UdpStreamAsyncio,
)


def _set_result(future, result):
Expand Down
1 change: 0 additions & 1 deletion src/spead2/send/asyncio.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ from typing import List, Optional, Union, overload

import spead2
import spead2.send

from spead2 import _EndpointList

class AsyncStream(spead2.send.Stream):
Expand Down
Loading

0 comments on commit f5d0033

Please sign in to comment.