Skip to content

chore: sort all imports using isort + check in CI #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "isort check"

on: [push, pull_request]
jobs:
pytest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.13"]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dev Dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Check Import Order
run: |
make check-isort
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ mypy:

test-extended:
pytest

run-isort:
isort .

check-isort:
isort . --check
2 changes: 1 addition & 1 deletion pydifact/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

from pydifact import segmentcollection, parser, segments, serializer, token, tokenizer
from pydifact import parser, segmentcollection, segments, serializer, token, tokenizer

__version__ = "0.1.8"

Expand Down
6 changes: 3 additions & 3 deletions pydifact/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

from collections.abc import Iterator

from pydifact.control import Characters
from pydifact.exceptions import EDISyntaxError
from pydifact.tokenizer import Tokenizer
from pydifact.token import Token
from pydifact.segments import Element, Elements, Segment, SegmentFactory
from pydifact.control import Characters
from pydifact.token import Token
from pydifact.tokenizer import Tokenizer


class Parser:
Expand Down
3 changes: 1 addition & 2 deletions pydifact/segmentcollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import datetime
from collections.abc import Callable, Iterable, Iterator, Sequence
from typing import Type, TypeVar
from collections.abc import Callable, Iterable

from pydifact.exceptions import EDISyntaxError
from pydifact.control import Characters
from pydifact.exceptions import EDISyntaxError
from pydifact.parser import Parser
from pydifact.segments import Element, Elements, Segment
from pydifact.serializer import Serializer
Expand Down
6 changes: 3 additions & 3 deletions pydifact/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

from pydifact.constants import EDI_DEFAULT_VERSION, M
from pydifact.exceptions import (
ValidationError,
MissingImplementationWarning,
EDISyntaxError,
MissingImplementationWarning,
ValidationError,
)
from pydifact.syntax.common import DataElement, CompositeDataElement
from pydifact.syntax.common import CompositeDataElement, DataElement


class Segment:
Expand Down
2 changes: 1 addition & 1 deletion pydifact/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
from pydifact.control.characters import Characters
import re

from pydifact.control.characters import Characters
from pydifact.segments import Segment


Expand Down
2 changes: 1 addition & 1 deletion pydifact/syntax/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import re
import warnings
from typing import Optional, Type, TypeAlias, TypeVar, NamedTuple
from typing import NamedTuple, Optional, Type, TypeAlias, TypeVar

from pydifact.constants import EDI_DEFAULT_VERSION
from pydifact.exceptions import ValidationError
Expand Down
8 changes: 4 additions & 4 deletions pydifact/syntax/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from pydifact.constants import C, M
from pydifact.segments import Segment
from pydifact.syntax.common import (
DataElement,
CompositeDataElement,
DataElement,
SyntaxVersionNumber,
)
from pydifact.constants import M, C
from pydifact.segments import Segment

__version__ = 1

from .data import partner_identification_codes
from ... import Characters
from .data import partner_identification_codes


class ServiceStringAdvice(DataElement):
Expand Down
5 changes: 3 additions & 2 deletions pydifact/syntax/v4/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from typing import NamedTuple

from pydifact.constants import M, C
from pydifact.constants import C, M
from pydifact.syntax import v1, v2, v3
from pydifact.syntax.common import (
DataElement,
CompositeDataElement,
DataElement,
SyntaxVersionNumber,
)

from .data import partner_identification_codes

__version__ = 4
Expand Down
2 changes: 1 addition & 1 deletion pydifact/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# THE SOFTWARE.
from collections.abc import Iterator

from pydifact.control.characters import Characters
from pydifact.exceptions import EDISyntaxError
from pydifact.token import Token
from pydifact.control.characters import Characters


class Tokenizer:
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ dev = [
"sphinx-rtd-theme>=2.0.0",
"build",
"twine",
"mypy>=1.15.0"
]
"mypy>=1.15.0",
"isort==6.0.1"
]

[tool.isort]
profile = "black"

[project.urls]
Documentation = "https://pydifact.readthedocs.io"
Expand Down
1 change: 1 addition & 0 deletions tests/messagetypes/paxlst/test_una.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# 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 pytest

from pydifact.control import Characters


Expand Down
1 change: 1 addition & 0 deletions tests/test_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import pytest

from pydifact.control import Characters


Expand Down
5 changes: 3 additions & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
#
# 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 pytest

from pydifact.control.characters import Characters
from pydifact.exceptions import EDISyntaxError
from pydifact.parser import Parser
from pydifact.segments import Segment
from pydifact.control.characters import Characters
import pytest

# @pytest.fixture
# def mocked_tokenizer(mocker):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sage_coala.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,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 os

from pydifact.segmentcollection import Interchange
from pydifact.segments import Segment


path = os.path.dirname(os.path.realpath(__file__)) + "/data"


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

from pydifact.segments import Segment


elements = ["field1", ["field2", "extra"], "stuff"]


Expand Down
3 changes: 2 additions & 1 deletion tests/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import copy
import datetime

import pytest

from pydifact.segmentcollection import RawSegmentCollection, Interchange
from pydifact.segmentcollection import Interchange, RawSegmentCollection
from pydifact.segments import Segment
from pydifact.serializer import Serializer

Expand Down
4 changes: 2 additions & 2 deletions tests/test_syntax_v1.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from pydifact import Serializer
from pydifact.exceptions import ValidationError
from pydifact.segments import Segment
import pytest

from pydifact.syntax.v1 import UNASegment

default_characters = ":+,? '"
Expand Down
3 changes: 1 addition & 2 deletions tests/test_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest

from pydifact.control import Characters
from pydifact.exceptions import EDISyntaxError
from pydifact.token import Token
from pydifact.tokenizer import Tokenizer

from pydifact.control import Characters


@pytest.fixture
def tokenizer() -> Tokenizer:
Expand Down