Skip to content

Commit

Permalink
Apply import sort fixers from ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 3, 2025
1 parent 2a95f57 commit 2917dc4
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 48 deletions.
7 changes: 2 additions & 5 deletions importlib_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
"""

from ._common import (
Anchor,
Package,
as_file,
files,
Package,
Anchor,
)

from ._functional import (
contents,
is_resource,
Expand All @@ -23,10 +22,8 @@
read_binary,
read_text,
)

from .abc import ResourceReader


__all__ = [
'Package',
'Anchor',
Expand Down
12 changes: 6 additions & 6 deletions importlib_resources/_common.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import contextlib
import functools
import importlib
import inspect
import itertools
import os
import pathlib
import tempfile
import functools
import contextlib
import types
import importlib
import inspect
import warnings
import itertools
from typing import Optional, Union, cast

from typing import Union, Optional, cast
from .abc import ResourceReader, Traversable

Package = Union[types.ModuleType, str]
Expand Down
3 changes: 1 addition & 2 deletions importlib_resources/_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import warnings

from ._common import files, as_file

from ._common import as_file, files

_MISSING = object()

Expand Down
14 changes: 11 additions & 3 deletions importlib_resources/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
import io
import itertools
import pathlib
from typing import Any, BinaryIO, Iterable, Iterator, NoReturn, Text, Optional
from typing import runtime_checkable, Protocol
from typing import (
Any,
BinaryIO,
Iterable,
Iterator,
NoReturn,
Optional,
Protocol,
Text,
runtime_checkable,
)

from .compat.py38 import StrPath


__all__ = ["ResourceReader", "Traversable", "TraversableResources"]


Expand Down
2 changes: 0 additions & 2 deletions importlib_resources/compat/py38.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import os
import sys

from typing import Union


if sys.version_info >= (3, 9):
StrPath = Union[str, os.PathLike[str]]
else:
Expand Down
1 change: 0 additions & 1 deletion importlib_resources/compat/py39.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys


__all__ = ['ZipPath']


Expand Down
2 changes: 1 addition & 1 deletion importlib_resources/future/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from contextlib import suppress
from types import SimpleNamespace

from .. import readers, _adapters
from .. import _adapters, readers


def _block_standard(reader_getter):
Expand Down
3 changes: 1 addition & 2 deletions importlib_resources/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import collections
import contextlib
import itertools
import pathlib
import operator
import pathlib
import re
import warnings
from collections.abc import Iterator

from . import abc

from ._itertools import only
from .compat.py39 import ZipPath

Expand Down
8 changes: 2 additions & 6 deletions importlib_resources/tests/_path.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import pathlib
import functools

from typing import Dict, Union
from typing import runtime_checkable
from typing import Protocol

import pathlib
from typing import Dict, Protocol, Union, runtime_checkable

####
# from jaraco.path 3.7.1
Expand Down
1 change: 0 additions & 1 deletion importlib_resources/tests/test_compatibilty_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import unittest

import importlib_resources as resources

from importlib_resources._adapters import (
CompatibilityFiles,
wrap_spec,
Expand Down
1 change: 1 addition & 0 deletions importlib_resources/tests/test_contents.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import importlib_resources as resources

from . import util
Expand Down
5 changes: 3 additions & 2 deletions importlib_resources/tests/test_custom.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import unittest
import contextlib
import pathlib
import unittest

import importlib_resources as resources

from .. import abc
from ..abc import TraversableResources, ResourceReader
from ..abc import ResourceReader, TraversableResources
from . import util
from .compat.py39 import os_helper

Expand Down
7 changes: 4 additions & 3 deletions importlib_resources/tests/test_files.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import contextlib
import importlib
import pathlib
import py_compile
import textwrap
import unittest
import warnings
import importlib
import contextlib

import importlib_resources as resources

from ..abc import Traversable
from . import util
from .compat.py39 import os_helper, import_helper
from .compat.py39 import import_helper, os_helper


@contextlib.contextmanager
Expand Down
7 changes: 3 additions & 4 deletions importlib_resources/tests/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import unittest
import os
import importlib

from .compat.py39 import warnings_helper
import os
import unittest

import importlib_resources as resources

from . import util
from .compat.py39 import warnings_helper

# Since the functional API forwards to Traversable, we only test
# filesystem resources here -- not zip files, namespace packages etc.
Expand Down
1 change: 1 addition & 0 deletions importlib_resources/tests/test_open.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest

import importlib_resources as resources

from . import util


Expand Down
1 change: 1 addition & 0 deletions importlib_resources/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import unittest

import importlib_resources as resources

from . import util


Expand Down
3 changes: 2 additions & 1 deletion importlib_resources/tests/test_read.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import unittest
from importlib import import_module

import importlib_resources as resources

from . import util
from importlib import import_module


class CommonBinaryTests(util.CommonTests, unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion importlib_resources/tests/test_reader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os.path
import pathlib
import unittest

from importlib import import_module

from importlib_resources.readers import MultiplexedPath, NamespaceReader

from . import util
Expand Down
3 changes: 2 additions & 1 deletion importlib_resources/tests/test_resource.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import unittest
from importlib import import_module

import importlib_resources as resources

from . import util
from importlib import import_module


class ResourceTests:
Expand Down
12 changes: 5 additions & 7 deletions importlib_resources/tests/util.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import abc
import contextlib
import importlib
import io
import pathlib
import sys
import types
import pathlib
import contextlib
from importlib.machinery import ModuleSpec

from ..abc import ResourceReader
from .compat.py39 import import_helper, os_helper
from . import zip as zip_
from . import _path


from importlib.machinery import ModuleSpec
from . import zip as zip_
from .compat.py39 import import_helper, os_helper


class Reader(ResourceReader):
Expand Down

0 comments on commit 2917dc4

Please sign in to comment.