Skip to content

Commit be653f0

Browse files
committed
chore: move Descriptor type alias to oras/types.py
The Descriptor type is now defined alongside container_type in oras/types.py, the project's established home for cross-cutting type aliases. oras/copy/descriptor.py re-exports it for backward compatibility, so existing imports continue to work. Signed-off-by: jiwangCHEN <hyper1char@gmail.com>
1 parent 9a2c3aa commit be653f0

10 files changed

Lines changed: 27 additions & 13 deletions

File tree

oras/copy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
)
5050
from oras.copy.adapters import LayoutTarget, RegistryTarget
5151
from oras.copy.copy import copy
52-
from oras.copy.descriptor import Descriptor
5352
from oras.copy.errors import CopyError, CopyErrorOrigin
5453
from oras.copy.graph import SkipNode
5554
from oras.copy.options import CopyGraphOptions, CopyOptions
55+
from oras.types import Descriptor
5656

5757
__all__ = [
5858
# Core function

oras/copy/adapters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222

2323
import oras.defaults
2424
import oras.utils
25-
from oras.copy.descriptor import Descriptor, is_manifest
25+
from oras.copy.descriptor import is_manifest
2626
from oras.layout.layout import Layout
2727
from oras.provider import Registry
28+
from oras.types import Descriptor
2829
from oras.utils.fileio import read_json
2930

3031
_VALID_DIGEST_RE = re.compile(r"^[a-z0-9]+:[a-f0-9]+$")

oras/copy/content.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import threading
1616
from typing import BinaryIO, Callable, List, Optional, Protocol, Tuple, runtime_checkable
1717

18-
from oras.copy.descriptor import Descriptor
18+
from oras.types import Descriptor
1919

2020

2121
# ---------------------------------------------------------------------------

oras/copy/copy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
from typing import Optional
1818

1919
from oras.copy import content as content_mod
20-
from oras.copy.descriptor import Descriptor, descriptors_equal
20+
from oras.copy.descriptor import descriptors_equal
2121
from oras.copy.errors import CopyError, CopyErrorOrigin
2222
from oras.copy.graph import SkipNode, copy_graph
2323
from oras.copy.options import DEFAULT_MAX_METADATA_BYTES, CopyOptions
24+
from oras.types import Descriptor
2425

2526

2627
def copy(

oras/copy/descriptor.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88
__author__ = "The ORAS Authors"
99
__license__ = "Apache-2.0"
1010

11-
from typing import Any, Dict, Tuple
12-
13-
# Type alias for OCI descriptors (plain dicts in oras-py)
14-
Descriptor = Dict[str, Any]
11+
from typing import Tuple
12+
13+
from oras.types import Descriptor
14+
15+
__all__ = [
16+
"Descriptor",
17+
"is_manifest",
18+
"is_foreign_layer",
19+
"descriptor_key",
20+
"descriptors_equal",
21+
"remove_foreign_layers",
22+
]
1523

1624
# OCI and Docker manifest media types
1725
_MANIFEST_MEDIA_TYPES = frozenset(

oras/copy/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
from oras.copy import content as content_mod
2121
from oras.copy.descriptor import (
22-
Descriptor,
2322
descriptors_equal,
2423
is_manifest,
2524
remove_foreign_layers,
2625
)
26+
from oras.types import Descriptor
2727
from oras.copy.errors import CopyError, CopyErrorOrigin
2828
from oras.copy.options import (
2929
DEFAULT_CONCURRENCY,

oras/copy/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from dataclasses import dataclass, field
1212
from typing import Callable, List, Optional
1313

14-
from oras.copy.descriptor import Descriptor
14+
from oras.types import Descriptor
1515

1616
# Default concurrency matches dockerd and containerd (3 concurrent copies)
1717
DEFAULT_CONCURRENCY: int = 3

oras/copy/tracker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
import threading
1313
from typing import Tuple
1414

15-
from oras.copy.descriptor import Descriptor, descriptor_key
15+
from oras.copy.descriptor import descriptor_key
16+
from oras.types import Descriptor
1617

1718

1819
class StatusTracker:

oras/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88

9-
from oras.copy.descriptor import Descriptor
9+
from oras.types import Descriptor
1010

1111

1212
class InMemoryTarget:

oras/types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
__copyright__ = "Copyright The ORAS Authors."
33
__license__ = "Apache-2.0"
44

5-
from typing import Union
5+
from typing import Any, Dict, Union
66

77
import oras.container
88

99
# container type can be string or container
1010
container_type = Union[str, oras.container.Container]
11+
12+
# OCI content descriptor (mediaType + digest + size, plus optional fields)
13+
Descriptor = Dict[str, Any]

0 commit comments

Comments
 (0)