diff --git a/ci/check.sh b/ci/check.sh index 9da7a8b..0b24f15 100755 --- a/ci/check.sh +++ b/ci/check.sh @@ -46,6 +46,7 @@ fi banner "Executing in conda environment ${CONDA_DEFAULT_ENV} in directory ${root}" run "Unit Tests" "python -m pytest -vv -r sx pybedlite" run "Style Checking" "black --line-length 99 $black_extra_args pybedlite" +run "Import sorting" "isort --force-single-line-imports --profile black pybedlite" run "Linting" "flake8 --config=$parent/flake8.cfg pybedlite" run "Type Checking" "mypy -p pybedlite --config $parent/mypy.ini" diff --git a/pybedlite/__init__.py b/pybedlite/__init__.py index 0672484..7befef8 100644 --- a/pybedlite/__init__.py +++ b/pybedlite/__init__.py @@ -53,11 +53,11 @@ from typing import Optional -from pybedlite.bed_writer import BedWriter -from pybedlite.bed_source import BedSource -from pybedlite.bed_source import BedPath from pybedlite.bed_record import BedRecord from pybedlite.bed_record import BedStrand +from pybedlite.bed_source import BedPath +from pybedlite.bed_source import BedSource +from pybedlite.bed_writer import BedWriter def reader(path: BedPath) -> "BedSource": diff --git a/pybedlite/bed_record.py b/pybedlite/bed_record.py index 72ecbbb..b1f72d2 100644 --- a/pybedlite/bed_record.py +++ b/pybedlite/bed_record.py @@ -14,14 +14,15 @@ from __future__ import annotations -import attr import enum +from typing import TYPE_CHECKING +from typing import ClassVar +from typing import List from typing import Optional from typing import Tuple -from typing import List -from typing import ClassVar from typing import Type -from typing import TYPE_CHECKING + +import attr if TYPE_CHECKING: from pybedlite.overlap_detector import Interval diff --git a/pybedlite/bed_source.py b/pybedlite/bed_source.py index ee8eb13..70c2136 100644 --- a/pybedlite/bed_source.py +++ b/pybedlite/bed_source.py @@ -12,24 +12,24 @@ """ import io -from typing import IO -from typing import Optional -from typing import TypeVar -from typing import Union -from typing import Type -from typing import Tuple -from typing import List from pathlib import Path from types import TracebackType +from typing import IO +from typing import Any from typing import Callable from typing import ContextManager +from typing import Dict from typing import Iterable from typing import Iterator -from typing import Dict -from typing import Any +from typing import List +from typing import Optional +from typing import Tuple +from typing import Type +from typing import TypeVar +from typing import Union -from pybedlite.bed_record import BedStrand from pybedlite.bed_record import BedRecord +from pybedlite.bed_record import BedStrand """The classes that should be treated as file-like classes""" _IOClasses = (io.TextIOBase, io.BufferedIOBase, io.RawIOBase, io.IOBase) diff --git a/pybedlite/bed_writer.py b/pybedlite/bed_writer.py index d6c9c9a..4abc2b4 100644 --- a/pybedlite/bed_writer.py +++ b/pybedlite/bed_writer.py @@ -10,19 +10,18 @@ - :class:`~pybedtools.bed_source.BedWriter` -- Writer class for writing BED files """ -from typing import IO -from typing import Optional -from typing import Type from pathlib import Path from types import TracebackType +from typing import IO from typing import ContextManager from typing import Iterable +from typing import Optional +from typing import Type from pybedlite.bed_record import BedRecord from pybedlite.bed_source import BedPath from pybedlite.bed_source import _IOClasses - """Maximum BED fields that can be present in a well formed BED file written to specification""" MAX_BED_FIELDS: int = 12 diff --git a/pybedlite/overlap_detector.py b/pybedlite/overlap_detector.py index 281bf77..ad546c5 100644 --- a/pybedlite/overlap_detector.py +++ b/pybedlite/overlap_detector.py @@ -49,11 +49,11 @@ from typing import Type import attr -import cgranges as cr +import cgranges as cr +from pybedlite.bed_record import BedRecord from pybedlite.bed_record import BedStrand from pybedlite.bed_source import BedSource -from pybedlite.bed_record import BedRecord @attr.s(frozen=True, auto_attribs=True) diff --git a/pybedlite/tests/conftest.py b/pybedlite/tests/conftest.py index 30b21f9..7d2ce54 100644 --- a/pybedlite/tests/conftest.py +++ b/pybedlite/tests/conftest.py @@ -1,5 +1,7 @@ -import pytest from typing import List + +import pytest + from pybedlite.bed_record import BedRecord from pybedlite.bed_record import BedStrand diff --git a/pybedlite/tests/test_overlap_detector.py b/pybedlite/tests/test_overlap_detector.py index e8e9fd5..dae34a9 100644 --- a/pybedlite/tests/test_overlap_detector.py +++ b/pybedlite/tests/test_overlap_detector.py @@ -2,10 +2,10 @@ from typing import List +from pybedlite.bed_record import BedRecord +from pybedlite.bed_record import BedStrand from pybedlite.overlap_detector import Interval from pybedlite.overlap_detector import OverlapDetector -from pybedlite.bed_record import BedStrand -from pybedlite.bed_record import BedRecord def run_test(targets: List[Interval], query: Interval, results: List[Interval]) -> None: diff --git a/pybedlite/tests/test_pybedlite.py b/pybedlite/tests/test_pybedlite.py index 1843538..a830bf7 100644 --- a/pybedlite/tests/test_pybedlite.py +++ b/pybedlite/tests/test_pybedlite.py @@ -1,14 +1,15 @@ """Tests for :py:mod:`~pybedlite.__init__.py`""" -import pytest from pathlib import Path from typing import List + +import pytest + import pybedlite as pybed +from pybedlite.bed_record import BedRecord +from pybedlite.bed_source import BedSource from pybedlite.bed_writer import MAX_BED_FIELDS from pybedlite.bed_writer import BedWriter -from pybedlite.bed_source import BedSource -from pybedlite.bed_record import BedRecord - SNIPPET_BED = """\ # Test header, with a line with whitespace below it.