Skip to content

Commit 2692cb9

Browse files
authored
Fix missing transfer syntax warnings (#1048)
1 parent 6d21818 commit 2692cb9

File tree

7 files changed

+41
-17
lines changed

7 files changed

+41
-17
lines changed

docs/changelog/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Releases
77
.. toctree::
88
:maxdepth: 1
99

10+
v3.0.4
1011
v3.0.3
1112
v3.0.2
1213
v3.0.1

docs/changelog/v3.0.4.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. _v3.0.4:
2+
3+
3.0.4
4+
=====
5+
6+
Fixes
7+
-----
8+
9+
Fixed unknown transfer syntax warnings due to pydicom v3.0 using an older version of the
10+
DICOM Standard.

pynetdicom/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,24 @@
22

33
import logging
44

5+
from pydicom._uid_dict import UID_dictionary
56
from pydicom.uid import UID
67

78
from ._version import __version__
89

910

11+
# fmt: off
12+
# Update pydicom's UID dictionary with any missing transfer syntaxes
13+
UID_dictionary.update(
14+
{
15+
'1.2.840.10008.1.2.4.110': ('JPEG XL Lossless', 'Transfer Syntax', '', '', 'JPEGXLLossless'),
16+
'1.2.840.10008.1.2.4.111': ('JPEG XL JPEG Recompression', 'Transfer Syntax', '', '', 'JPEGXLJPEGRecompression'),
17+
'1.2.840.10008.1.2.4.112': ('JPEG XL', 'Transfer Syntax', '', '', 'JPEGXL'),
18+
'1.2.840.10008.1.2.8.1': ('Deflated Image Frame Compression', 'Transfer Syntax', '', '', 'DeflatedImageFrameCompression'),
19+
}
20+
)
21+
# fmt: on
22+
1023
_version = __version__.split(".")[:3]
1124

1225
# UID prefix provided by https://www.medicalconnections.co.uk/Free_UID

pynetdicom/presentation.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,7 @@ class PresentationContextTuple(NamedTuple):
119119
(False, True): CONTEXT_REJECTED, # Invalid
120120
},
121121
}
122-
# Transfer Syntaxes not in pydicom v2.4
123-
_PYDICOM_ADDITIONS = [
124-
"1.2.840.10008.1.2.4.201", # HTJ2KLossless
125-
"1.2.840.10008.1.2.4.202", # HTJ2KLosslessRPCL
126-
"1.2.840.10008.1.2.4.203", # HTJ2K
127-
"1.2.840.10008.1.2.4.204", # JPIPHTJ2KReferenced
128-
"1.2.840.10008.1.2.4.205", # JPIPHTJ2KReferencedDeflate
129-
]
122+
130123

131124
class PresentationContext:
132125
"""A Presentation Context primitive.
@@ -279,11 +272,7 @@ def add_transfer_syntax(self, syntax: None | str | bytes | UID) -> None:
279272
"A non-conformant UID has been added to 'transfer_syntax'"
280273
)
281274

282-
if (
283-
not syntax.is_private
284-
and not syntax.is_transfer_syntax
285-
and syntax not in _PYDICOM_ADDITIONS
286-
):
275+
if not syntax.is_private and not syntax.is_transfer_syntax:
287276
LOGGER.warning(
288277
"A UID has been added to 'transfer_syntax' that is not a "
289278
f"transfer syntax: '{syntax}'"

pynetdicom/tests/test_presentation.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pydicom.uid import UID
1111

1212
from pynetdicom import AE, _config
13-
from pynetdicom._globals import DEFAULT_TRANSFER_SYNTAXES
13+
from pynetdicom._globals import DEFAULT_TRANSFER_SYNTAXES, ALL_TRANSFER_SYNTAXES
1414
from pynetdicom.pdu_primitives import SCP_SCU_RoleSelectionNegotiation
1515
from pynetdicom.presentation import (
1616
build_context,
@@ -433,6 +433,17 @@ def test_repr(self):
433433
cx = build_context("1.2.840.10008.1.1")
434434
assert "Verification SOP Class" == repr(cx)
435435

436+
def test_transfer_syntaxes_dont_warn(self, caplog):
437+
"""Test that all transfer syntaxes are known to pydicom"""
438+
caplog.set_level(logging.WARNING, logger="pynetdicom.presentation")
439+
for ts in ALL_TRANSFER_SYNTAXES:
440+
cx = build_context("1.2.3", ts)
441+
442+
for ts in DEFAULT_TRANSFER_SYNTAXES:
443+
cx = build_context("1.2.3", ts)
444+
445+
assert caplog.text == ""
446+
436447

437448
class TestNegotiateAsAcceptor:
438449
"""Tests negotiation_as_acceptor."""

pynetdicom/transport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,12 +852,12 @@ def __init__(
852852
self.address_info = AddressInformation.from_tuple(address)
853853
self.address_family = self.address_info.address_family
854854
self.allow_reuse_address = True
855-
self.server_address: tuple[str, int] | tuple[str, int, int, int] = address # type: ignore[assignment]
855+
self.server_address: tuple[str, int] | tuple[str, int, int, int] = address
856856
self.socket: socket.socket | None = None # type: ignore[assignment]
857857

858858
request_handler = request_handler or RequestHandler
859859

860-
super().__init__(address, request_handler, bind_and_activate=True) # type: ignore[arg-type]
860+
super().__init__(address, request_handler, bind_and_activate=True)
861861

862862
self.timeout = 60
863863

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ maintainers = [
3030
]
3131
name = "pynetdicom"
3232
readme = "README.rst"
33-
version = "3.0.3"
33+
version = "3.0.4"
3434
requires-python = ">=3.10"
3535
dependencies = ["pydicom >=3, <4"]
3636

0 commit comments

Comments
 (0)