Skip to content

Commit

Permalink
chore: Add isort to code checks (#32)
Browse files Browse the repository at this point in the history
* chore: isort

* build: add isort to GHA

* build: add isort to dev dependencies
  • Loading branch information
msto authored Apr 24, 2024
1 parent 533567b commit 34ef50e
Show file tree
Hide file tree
Showing 12 changed files with 387 additions and 341 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ jobs:
run: |
poetry run black --line-length 99 --check pybedlite
- name: Import sorting
shell: bash
run: |
poetry run isort --force-single-line-imports --profile black --check pybedlite
- name: Run lint
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions ci/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
656 changes: 346 additions & 310 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pybedlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
9 changes: 5 additions & 4 deletions pybedlite/bed_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions pybedlite/bed_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions pybedlite/bed_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions pybedlite/overlap_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion pybedlite/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
from typing import List

import pytest

from pybedlite.bed_record import BedRecord
from pybedlite.bed_record import BedStrand

Expand Down
4 changes: 2 additions & 2 deletions pybedlite/tests/test_overlap_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 6 additions & 5 deletions pybedlite/tests/test_pybedlite.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"""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_writer import MAX_BED_FIELDS
from pybedlite.bed_writer import BedWriter
from pybedlite.bed_source import BedSource
from pybedlite.bed_record import BedRecord
from pybedlite.bed_record import BedStrand

from pybedlite.bed_source import BedSource
from pybedlite.bed_writer import MAX_BED_FIELDS
from pybedlite.bed_writer import BedWriter

SNIPPET_BED = """\
# Test header, with a line with whitespace below it.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pytest = "^7.0.0"
mypy = "^1.5.0"
flake8 = "^5.0.0"
black = "^23.0.0"
isort = "^5.13.0"
pytest-cov = "^4.0.0"

[tool.poetry.extras]
Expand Down

0 comments on commit 34ef50e

Please sign in to comment.