16
16
from __future__ import annotations
17
17
18
18
import sys
19
+ from typing import Literal
19
20
20
21
if not sys .argv [0 ].endswith ('pdoc' ):
21
22
from dicom_echo .backend import ( # pylint: disable=no-name-in-module
22
23
DEFAULT_CALLED_AE_TITLE ,
23
24
DEFAULT_CALLING_AE_TITLE ,
24
25
)
25
26
from dicom_echo .backend import send as __send # pylint: disable=no-name-in-module
26
- else :
27
- DEFAULT_CALLED_AE_TITLE = 'ANY-SCP' # pyright: ignore[reportConstantRedefinition]
28
- DEFAULT_CALLING_AE_TITLE = 'ECHOSCU' # pyright: ignore[reportConstantRedefinition]
27
+ else : # pragma: no cover
28
+ # copy `backend.pyi` contents so the documentation can be built without cargo
29
+
30
+ DEFAULT_CALLED_AE_TITLE : Literal ['ANY-SCP' ] = 'ANY-SCP' # type: ignore[no-redef]
31
+ """By default, specify this AE title for the target SCP."""
32
+
33
+ DEFAULT_CALLING_AE_TITLE : Literal ['ECHOSCU' ] = 'ECHOSCU' # type: ignore[no-redef]
34
+ """By default, specify this AE title for the SCU sending the `C-ECHO` message."""
29
35
30
36
def __send (
31
37
address : str ,
@@ -41,7 +47,7 @@ def __send(
41
47
return 0
42
48
43
49
44
- __all__ = ['DEFAULT_CALLED_AE_TITLE' , 'DEFAULT_CALLING_AE_TITLE' , 'send' ]
50
+ __all__ = ['DEFAULT_CALLED_AE_TITLE' , 'DEFAULT_CALLING_AE_TITLE' , 'Counter' , ' send' ]
45
51
46
52
__version__ = '0.0.0'
47
53
__version_tuple__ = (0 , 0 , 0 )
@@ -58,27 +64,22 @@ def increment(self) -> int:
58
64
return self .count
59
65
60
66
61
- class Sentinel :
62
- """Explicitly define a class for the sentinel object for type annotations."""
63
-
64
-
65
67
counter = Counter ()
66
- sentinel = Sentinel ()
67
68
68
69
69
70
def send (
70
71
address : str ,
71
72
/ ,
72
73
called_ae_title : str = DEFAULT_CALLED_AE_TITLE ,
73
74
calling_ae_title : str = DEFAULT_CALLING_AE_TITLE ,
74
- message_id : int | Sentinel = sentinel ,
75
+ message_id : int | Counter = counter ,
75
76
) -> int :
76
77
"""Send a `C-ECHO` message to the given address.
77
78
78
- If `message_id` is not overwritten , a global counter will be incremented and passed.
79
+ If `message_id` is not provided , a global counter will be incremented and passed.
79
80
80
81
Reference: [DICOM Standard Part 7, Section 9.1.5](https://www.dicomstandard.org/standards/view/message-exchange#sect_9.1.5)
81
82
"""
82
- if isinstance (message_id , Sentinel ):
83
+ if isinstance (message_id , Counter ):
83
84
message_id = counter .increment ()
84
85
return __send (address , called_ae_title = called_ae_title , calling_ae_title = calling_ae_title , message_id = message_id )
0 commit comments