diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0ac84374e..e1482ea4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -exclude: "asdf/(extern||_jsonschema)/.*" +exclude: "asdf/(_extern||_jsonschema)/.*" repos: - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/asdf/_block/io.py b/asdf/_block/io.py index ce93f9a11..bfb1c3338 100644 --- a/asdf/_block/io.py +++ b/asdf/_block/io.py @@ -10,7 +10,7 @@ import yaml -from asdf import compression as mcompression +from asdf import _compression as mcompression from asdf import constants, util from .exceptions import BlockIndexError diff --git a/asdf/_block/options.py b/asdf/_block/options.py index 1ced09478..04cde9dff 100644 --- a/asdf/_block/options.py +++ b/asdf/_block/options.py @@ -1,4 +1,4 @@ -from asdf import compression as mcompression +from asdf import _compression as mcompression from asdf.config import get_config diff --git a/asdf/compression.py b/asdf/_compression.py similarity index 100% rename from asdf/compression.py rename to asdf/_compression.py diff --git a/asdf/core/__init__.py b/asdf/_core/__init__.py similarity index 100% rename from asdf/core/__init__.py rename to asdf/_core/__init__.py diff --git a/asdf/core/_converters/__init__.py b/asdf/_core/_converters/__init__.py similarity index 100% rename from asdf/core/_converters/__init__.py rename to asdf/_core/_converters/__init__.py diff --git a/asdf/core/_converters/complex.py b/asdf/_core/_converters/complex.py similarity index 100% rename from asdf/core/_converters/complex.py rename to asdf/_core/_converters/complex.py diff --git a/asdf/core/_converters/constant.py b/asdf/_core/_converters/constant.py similarity index 100% rename from asdf/core/_converters/constant.py rename to asdf/_core/_converters/constant.py diff --git a/asdf/core/_converters/external_reference.py b/asdf/_core/_converters/external_reference.py similarity index 100% rename from asdf/core/_converters/external_reference.py rename to asdf/_core/_converters/external_reference.py diff --git a/asdf/core/_converters/integer.py b/asdf/_core/_converters/integer.py similarity index 100% rename from asdf/core/_converters/integer.py rename to asdf/_core/_converters/integer.py diff --git a/asdf/core/_converters/ndarray.py b/asdf/_core/_converters/ndarray.py similarity index 100% rename from asdf/core/_converters/ndarray.py rename to asdf/_core/_converters/ndarray.py diff --git a/asdf/core/_converters/reference.py b/asdf/_core/_converters/reference.py similarity index 100% rename from asdf/core/_converters/reference.py rename to asdf/_core/_converters/reference.py diff --git a/asdf/core/_converters/tree.py b/asdf/_core/_converters/tree.py similarity index 100% rename from asdf/core/_converters/tree.py rename to asdf/_core/_converters/tree.py diff --git a/asdf/core/_extensions.py b/asdf/_core/_extensions.py similarity index 100% rename from asdf/core/_extensions.py rename to asdf/_core/_extensions.py diff --git a/asdf/core/_integration.py b/asdf/_core/_integration.py similarity index 100% rename from asdf/core/_integration.py rename to asdf/_core/_integration.py diff --git a/asdf/core/_validators/__init__.py b/asdf/_core/_validators/__init__.py similarity index 100% rename from asdf/core/_validators/__init__.py rename to asdf/_core/_validators/__init__.py diff --git a/asdf/core/_validators/ndarray.py b/asdf/_core/_validators/ndarray.py similarity index 100% rename from asdf/core/_validators/ndarray.py rename to asdf/_core/_validators/ndarray.py diff --git a/asdf/entry_points.py b/asdf/_entry_points.py similarity index 100% rename from asdf/entry_points.py rename to asdf/_entry_points.py diff --git a/asdf/extern/RangeHTTPServer.py b/asdf/_extern/RangeHTTPServer.py similarity index 100% rename from asdf/extern/RangeHTTPServer.py rename to asdf/_extern/RangeHTTPServer.py diff --git a/asdf/extern/__init__.py b/asdf/_extern/__init__.py similarity index 100% rename from asdf/extern/__init__.py rename to asdf/_extern/__init__.py diff --git a/asdf/extern/atomicfile.py b/asdf/_extern/atomicfile.py similarity index 100% rename from asdf/extern/atomicfile.py rename to asdf/_extern/atomicfile.py diff --git a/asdf/_tests/core/tests/test_integration.py b/asdf/_tests/core/tests/test_integration.py index b808dc729..1ef979978 100644 --- a/asdf/_tests/core/tests/test_integration.py +++ b/asdf/_tests/core/tests/test_integration.py @@ -2,7 +2,7 @@ import yaml import asdf -from asdf.core._integration import get_extensions, get_json_schema_resource_mappings +from asdf._core._integration import get_extensions, get_json_schema_resource_mappings @pytest.mark.parametrize( diff --git a/asdf/_tests/httpserver.py b/asdf/_tests/httpserver.py index 8e9d3956f..3de3f62d2 100644 --- a/asdf/_tests/httpserver.py +++ b/asdf/_tests/httpserver.py @@ -6,7 +6,7 @@ import tempfile import threading -from asdf.extern.RangeHTTPServer import RangeHTTPRequestHandler +from asdf._extern.RangeHTTPServer import RangeHTTPRequestHandler __all__ = ["HTTPServer", "RangeHTTPServer"] diff --git a/asdf/_tests/test_asdf.py b/asdf/_tests/test_asdf.py index 8584367d8..e5f56bf99 100644 --- a/asdf/_tests/test_asdf.py +++ b/asdf/_tests/test_asdf.py @@ -3,9 +3,9 @@ import pytest from asdf import config_context +from asdf._entry_points import get_extensions from asdf._tests._helpers import assert_no_warnings, assert_tree_match, yaml_to_asdf from asdf.asdf import AsdfFile, open_asdf -from asdf.entry_points import get_extensions from asdf.exceptions import AsdfWarning from asdf.extension import ExtensionProxy from asdf.versioning import AsdfVersion diff --git a/asdf/_tests/test_compression.py b/asdf/_tests/test_compression.py index 150d27cc5..091d405cf 100644 --- a/asdf/_tests/test_compression.py +++ b/asdf/_tests/test_compression.py @@ -6,7 +6,7 @@ import pytest import asdf -from asdf import compression, config_context, generic_io +from asdf import _compression, config_context, generic_io from asdf._tests import _helpers as helpers from asdf.extension import Compressor, Extension @@ -71,27 +71,27 @@ def test_invalid_compression(): with pytest.raises(ValueError, match=r"Invalid compression type: foo"): ff.set_array_compression(tree["science_data"], "foo") with pytest.raises(ValueError, match=r"Unknown compression type: .*"): - compression._get_compressor("foo") + _compression._get_compressor("foo") def test_get_compressed_size(): - assert compression.get_compressed_size(b"0" * 1024, "zlib") < 1024 + assert _compression.get_compressed_size(b"0" * 1024, "zlib") < 1024 def test_decompress_too_long_short(): fio = io.BytesIO() - compression.compress(fio, b"0" * 1024, "zlib") + _compression.compress(fio, b"0" * 1024, "zlib") size = fio.tell() fio.seek(0) blocks = lambda us: [fio.read(us)] # noqa: E731 fio.read_blocks = blocks - compression.decompress(fio, size, 1024, "zlib") + _compression.decompress(fio, size, 1024, "zlib") fio.seek(0) with pytest.raises(ValueError, match=r"Decompressed data wrong size"): - compression.decompress(fio, size, 1025, "zlib") + _compression.decompress(fio, size, 1025, "zlib") fio.seek(0) with pytest.raises(ValueError, match=r"memoryview assignment: lvalue and rvalue have different structures"): - compression.decompress(fio, size, 1023, "zlib") + _compression.decompress(fio, size, 1023, "zlib") def test_zlib(tmp_path): diff --git a/asdf/_tests/test_config.py b/asdf/_tests/test_config.py index 0b90ec14a..0e082deb3 100644 --- a/asdf/_tests/test_config.py +++ b/asdf/_tests/test_config.py @@ -5,7 +5,7 @@ import asdf from asdf import get_config -from asdf.core._integration import get_json_schema_resource_mappings +from asdf._core._integration import get_json_schema_resource_mappings from asdf.extension import ExtensionProxy from asdf.resource import ResourceMappingProxy diff --git a/asdf/_tests/test_entry_points.py b/asdf/_tests/test_entry_points.py index ec45ca05d..d53c85afc 100644 --- a/asdf/_tests/test_entry_points.py +++ b/asdf/_tests/test_entry_points.py @@ -6,7 +6,7 @@ import importlib_metadata as metadata import pytest -from asdf import entry_points +from asdf import _entry_points from asdf._version import version as asdf_package_version from asdf.exceptions import AsdfWarning from asdf.extension import ExtensionProxy @@ -20,7 +20,7 @@ def mock_entry_points(): @pytest.fixture(autouse=True) def _monkeypatch_entry_points(monkeypatch, mock_entry_points): - def _entry_points(*, group): + def patched_entry_points(*, group): for candidate_group, name, func_name in mock_entry_points: if candidate_group == group: point = metadata.EntryPoint(name=name, group=group, value=func_name) @@ -28,7 +28,7 @@ def _entry_points(*, group): yield point - monkeypatch.setattr(entry_points, "entry_points", _entry_points) + monkeypatch.setattr(_entry_points, "entry_points", patched_entry_points) def resource_mappings_entry_point_successful(): @@ -59,7 +59,7 @@ def test_get_resource_mappings(mock_entry_points): "asdf._tests.test_entry_points:resource_mappings_entry_point_successful", ), ) - mappings = entry_points.get_resource_mappings() + mappings = _entry_points.get_resource_mappings() assert len(mappings) == 2 for m in mappings: assert isinstance(m, ResourceMappingProxy) @@ -71,7 +71,7 @@ def test_get_resource_mappings(mock_entry_points): ("asdf.resource_mappings", "failing", "asdf._tests.test_entry_points:resource_mappings_entry_point_failing"), ) with pytest.warns(AsdfWarning, match=r"Exception: NOPE"): - mappings = entry_points.get_resource_mappings() + mappings = _entry_points.get_resource_mappings() assert len(mappings) == 0 mock_entry_points.clear() @@ -83,7 +83,7 @@ def test_get_resource_mappings(mock_entry_points): ), ) with pytest.warns(AsdfWarning, match=r"TypeError: Resource mapping must implement the Mapping interface"): - mappings = entry_points.get_resource_mappings() + mappings = _entry_points.get_resource_mappings() assert len(mappings) == 2 @@ -130,7 +130,7 @@ def test_get_extensions(mock_entry_points): mock_entry_points.append( ("asdf.extensions", "successful", "asdf._tests.test_entry_points:extensions_entry_point_successful"), ) - extensions = entry_points.get_extensions() + extensions = _entry_points.get_extensions() assert len(extensions) == 2 for e in extensions: assert isinstance(e, ExtensionProxy) @@ -142,7 +142,7 @@ def test_get_extensions(mock_entry_points): ("asdf.extensions", "failing", "asdf._tests.test_entry_points:extensions_entry_point_failing"), ) with pytest.warns(AsdfWarning, match=r"Exception: NOPE"): - extensions = entry_points.get_extensions() + extensions = _entry_points.get_extensions() assert len(extensions) == 0 mock_entry_points.clear() @@ -153,16 +153,16 @@ def test_get_extensions(mock_entry_points): AsdfWarning, match=r"TypeError: Extension must implement the Extension interface", ): - extensions = entry_points.get_extensions() + extensions = _entry_points.get_extensions() assert len(extensions) == 2 mock_entry_points.clear() mock_entry_points.append(("asdf_extensions", "legacy", "asdf._tests.test_entry_points:LegacyExtension")) - extensions = entry_points.get_extensions() + extensions = _entry_points.get_extensions() assert len(extensions) == 0 # asdf_extensions is no longer supported mock_entry_points.clear() mock_entry_points.append(("asdf.extensions", "failing", "asdf._tests.test_entry_points:FauxLegacyExtension")) with pytest.warns(AsdfWarning, match=r"TypeError"): - extensions = entry_points.get_extensions() + extensions = _entry_points.get_extensions() assert len(extensions) == 0 diff --git a/asdf/asdf.py b/asdf/asdf.py index 924274d8f..fc3ddadbd 100644 --- a/asdf/asdf.py +++ b/asdf/asdf.py @@ -8,10 +8,10 @@ from packaging.version import Version +from . import _compression as mcompression from . import _display as display from . import _node_info as node_info from . import _version as version -from . import compression as mcompression from . import constants, generic_io, reference, schema, treeutil, util, versioning, yamlutil from ._block.manager import Manager as BlockManager from ._helpers import validate_version diff --git a/asdf/commands/extension.py b/asdf/commands/extension.py index cc0d0e05e..08eabc665 100644 --- a/asdf/commands/extension.py +++ b/asdf/commands/extension.py @@ -1,7 +1,7 @@ """ Implementation of command for reporting information about installed extensions. """ -from asdf.entry_points import get_extensions +from asdf._entry_points import get_extensions from .main import Command diff --git a/asdf/config.py b/asdf/config.py index 911c7a9b3..8e2dd3ff9 100644 --- a/asdf/config.py +++ b/asdf/config.py @@ -7,7 +7,7 @@ import threading from contextlib import contextmanager -from . import entry_points, util, versioning +from . import _entry_points, util, versioning from ._helpers import validate_version from .extension import ExtensionProxy from .resource import ResourceManager, ResourceMappingProxy @@ -63,7 +63,7 @@ def resource_mappings(self): if self._resource_mappings is None: with self._lock: if self._resource_mappings is None: - self._resource_mappings = entry_points.get_resource_mappings() + self._resource_mappings = _entry_points.get_resource_mappings() return self._resource_mappings def add_resource_mapping(self, mapping): @@ -155,7 +155,7 @@ def extensions(self): if self._extensions is None: with self._lock: if self._extensions is None: - self._extensions = entry_points.get_extensions() + self._extensions = _entry_points.get_extensions() return self._extensions def add_extension(self, extension): @@ -371,7 +371,7 @@ def all_array_compression(self): @all_array_compression.setter def all_array_compression(self, value): # local to avoid circular import - from asdf.compression import validate + from asdf._compression import validate self._all_array_compression = validate(value) diff --git a/asdf/generic_io.py b/asdf/generic_io.py index 1ebe660fc..b63563a67 100644 --- a/asdf/generic_io.py +++ b/asdf/generic_io.py @@ -20,8 +20,8 @@ import numpy as np from . import util +from ._extern import atomicfile from .exceptions import DelimiterNotFoundError -from .extern import atomicfile from .util import _patched_urllib_parse __all__ = ["get_file", "get_uri", "resolve_uri", "relative_uri"] diff --git a/pyproject.toml b/pyproject.toml index 3f954c247..d6aac0724 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,8 +55,8 @@ tests = [ 'repository' = 'https://github.com/asdf-format/asdf' 'tracker' = 'https://github.com/asdf-format/asdf/issues' [project.entry-points] -'asdf.extensions' = {asdf = 'asdf.core._integration:get_extensions'} -'asdf.resource_mappings' = {asdf = 'asdf.core._integration:get_json_schema_resource_mappings'} +'asdf.extensions' = {asdf = 'asdf._core._integration:get_extensions'} +'asdf.resource_mappings' = {asdf = 'asdf._core._integration:get_json_schema_resource_mappings'} asdf_extensions = {builtin = 'asdf.extension._legacy:BuiltinExtension'} console_scripts = {asdftool = 'asdf.commands.main:main'} pytest11 = {asdf_schema_tester = 'pytest_asdf.plugin'} @@ -90,7 +90,7 @@ force-exclude = ''' | \.git | \.pytest_cache | \.tox - | asdf/extern + | asdf/_extern | asdf/_jsonschema | build | dist @@ -126,7 +126,7 @@ omit = [ 'asdf/*/*/tests/*', 'asdf/version.*', 'asdf/compat*', - 'asdf/extern*', + 'asdf/_extern*', 'asdf/_jsonschema/**', # And again for running against installed version '*/asdf/_astropy_init*', @@ -141,7 +141,7 @@ omit = [ '*/asdf/*/*/tests/*', '*/asdf/version.*', '*/asdf/compat*', - '*/asdf/extern*', + '*/asdf/_extern*', '*/asdf/_jsonschema/**', ] @@ -176,7 +176,7 @@ extend-ignore = [ "S310", # URL open for permitted schemes "RUF012", # mutable-class-default (typing related) ] -extend-exclude = ["asdf/extern/*", "asdf/_jsonschema/*", "docs/*"] +extend-exclude = ["asdf/_extern/*", "asdf/_jsonschema/*", "docs/*"] [tool.ruff.per-file-ignores] "test_*.py" = ["S101"] @@ -184,10 +184,10 @@ extend-exclude = ["asdf/extern/*", "asdf/_jsonschema/*", "docs/*"] "compatibility_tests/common.py" = ["S101"] [tool.flynt] -exclude = ["asdf/extern/*", "asdf/_jsonschema/*"] +exclude = ["asdf/_extern/*", "asdf/_jsonschema/*"] [tool.codespell] -skip="*.pdf,*.asdf,.tox,asdf/extern,asdf/_jsonschema,build,./tags,.git,docs/_build" +skip="*.pdf,*.asdf,.tox,asdf/_extern,asdf/_jsonschema,build,./tags,.git,docs/_build" ignore-words-list=""" fo,afile, """