Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pynetdicom/ae.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def add_supported_context(
else:
context = PresentationContext()
context.abstract_syntax = abstract_syntax
context.transfer_syntax = transfer_syntax # type: ignore
context.transfer_syntax = transfer_syntax # type: ignore[assignment]
context.scu_role = None or scu_role
context.scp_role = None or scp_role

Expand Down Expand Up @@ -873,7 +873,7 @@ def make_server(

server_class = server_class or AssociationServer # type: ignore[assignment]

return server_class( # type: ignore
return server_class( # type: ignore[call-arg, misc]
self,
address,
ae_title,
Expand Down
16 changes: 8 additions & 8 deletions pynetdicom/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
_UITypes,
)
from pynetdicom.presentation import PresentationContext
from pynetdicom.sop_class import ( # type: ignore
from pynetdicom.sop_class import ( # type: ignore[attr-defined]
RepositoryQuery,
uid_to_service_class,
UnifiedProcedureStepPull,
Expand Down Expand Up @@ -435,7 +435,7 @@ def _get_valid_context(
tr_syntax = UID(tr_syntax)

try:
possible_contexts = [self._accepted_cx[context_id]] # type: ignore
possible_contexts = [self._accepted_cx[context_id]] # type: ignore[index]
except KeyError:
possible_contexts = self.accepted_contexts

Expand Down Expand Up @@ -2430,7 +2430,7 @@ def send_n_action(
if category not in [STATUS_WARNING, STATUS_SUCCESS]:
return status, action_reply

b: BytesIO = rsp.ActionReply # type: ignore
b: BytesIO = rsp.ActionReply # type: ignore[assignment, union-attr]
if b and b.getvalue() != b"":
# Attempt to decode the response's dataset
try:
Expand Down Expand Up @@ -2667,7 +2667,7 @@ def send_n_create(
if category not in [STATUS_WARNING, STATUS_SUCCESS]:
return status, attribute_list

b: BytesIO = rsp.AttributeList # type: ignore
b: BytesIO = rsp.AttributeList # type: ignore[assignment, union-attr]
if b and b.getvalue() != b"":
# Attempt to decode the response's dataset
try:
Expand Down Expand Up @@ -2997,7 +2997,7 @@ def send_n_event_report(
if category not in [STATUS_WARNING, STATUS_SUCCESS]:
return status, event_reply

b: BytesIO = rsp.EventReply # type: ignore
b: BytesIO = rsp.EventReply # type: ignore[assignment, union-attr]
if b and b.getvalue() != b"":
# Attempt to decode the response"s dataset
try:
Expand Down Expand Up @@ -3204,7 +3204,7 @@ def send_n_get(
if category not in [STATUS_WARNING, STATUS_SUCCESS]:
return status, attribute_list

b: BytesIO = rsp.AttributeList # type: ignore
b: BytesIO = rsp.AttributeList # type: ignore[assignment, union-attr]
if b and b.getvalue() != b"":
# Attempt to decode the response"s dataset
try:
Expand Down Expand Up @@ -3454,7 +3454,7 @@ def send_n_set(
if category not in [STATUS_WARNING, STATUS_SUCCESS]:
return status, attribute_list

b: BytesIO = rsp.AttributeList # type: ignore
b: BytesIO = rsp.AttributeList # type: ignore[assignment, union-attr]
if b and b.getvalue() != b"":
# Attempt to decode the response's dataset
try:
Expand Down Expand Up @@ -3507,7 +3507,7 @@ def _serve_request(self, msg: DimseServiceType, context_id: int) -> None:
class_uid = cast(UID, msg.AffectedSOPClassUID)
elif getattr(msg, "RequestedSOPClassUID", None) is not None:
# N-GET, N-SET, N-ACTION, N-DELETE use RequestedSOPClassUID
class_uid = msg.RequestedSOPClassUID # type: ignore
class_uid = msg.RequestedSOPClassUID # type: ignore[assignment, union-attr]

# SOP Class Common Extended Negotiation
class_uid = cast(UID, class_uid)
Expand Down
2 changes: 1 addition & 1 deletion pynetdicom/dimse.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def send_msg(self, primitive: DimsePrimitiveType, context_id: int) -> None:
sent under.
"""
if primitive.MessageIDBeingRespondedTo is None:
dimse_msg = _RQ_TO_MESSAGE[primitive.__class__]() # type: ignore
dimse_msg = _RQ_TO_MESSAGE[primitive.__class__]() # type: ignore[index]
else:
dimse_msg = _RSP_TO_MESSAGE[primitive.__class__]()

Expand Down
2 changes: 1 addition & 1 deletion pynetdicom/dimse_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def decode_msg(self, primitive: P_DATA, assoc: "Association | None" = None) -> b
sop_class = cast(UID, cs.AffectedSOPClassUID)
sop_instance = cast(UID, cs.AffectedSOPInstanceUID)
write_file_meta_info(
self._data_set_file, # type: ignore
self._data_set_file, # type: ignore[arg-type]
create_file_meta(
sop_class_uid=sop_class,
sop_instance_uid=sop_instance,
Expand Down
2 changes: 1 addition & 1 deletion pynetdicom/dsutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def encode(
fp.close()
return None

bytestring: bytes = fp.parent.getvalue() # type: ignore
bytestring: bytes = fp.parent.getvalue() # type: ignore[union-attr]
fp.close()

if deflated:
Expand Down
28 changes: 14 additions & 14 deletions pynetdicom/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,32 @@ def __str__(self) -> str:


EVT_ABORTED = NotificationEvent("EVT_ABORTED", "Association aborted")
EVT_ACCEPTED = NotificationEvent("EVT_ACCEPTED", "Association request accepted") # noqa
EVT_ACCEPTED = NotificationEvent("EVT_ACCEPTED", "Association request accepted")
EVT_ACSE_RECV = NotificationEvent(
"EVT_ACSE_RECV", "ACSE primitive received from DUL"
) # noqa
EVT_ACSE_SENT = NotificationEvent("EVT_ACSE_SENT", "ACSE primitive sent to DUL") # noqa
)
EVT_ACSE_SENT = NotificationEvent("EVT_ACSE_SENT", "ACSE primitive sent to DUL")
EVT_CONN_CLOSE = NotificationEvent("EVT_CONN_CLOSE", "Connection closed")
EVT_CONN_OPEN = NotificationEvent("EVT_CONN_OPEN", "Connection opened")
EVT_DATA_RECV = NotificationEvent(
"EVT_DATA_RECV", "PDU data received from remote"
) # noqa
)
EVT_DATA_SENT = NotificationEvent("EVT_DATA_SENT", "PDU data sent to remote")
EVT_DIMSE_RECV = NotificationEvent(
"EVT_DIMSE_RECV", "Complete DIMSE message received and decoded"
) # noqa
)
EVT_DIMSE_SENT = NotificationEvent(
"EVT_DIMSE_SENT", "DIMSE message encoded and P-DATA primitives sent to DUL"
) # noqa
)
EVT_ESTABLISHED = NotificationEvent(
"EVT_ESTABLISHED", "Association established"
) # noqa
)
EVT_FSM_TRANSITION = NotificationEvent(
"EVT_FSM_TRANSITION", "State machine about to transition"
) # noqa
)
EVT_PDU_RECV = NotificationEvent("EVT_PDU_RECV", "PDU received and decoded")
EVT_PDU_SENT = NotificationEvent("EVT_PDU_SENT", "PDU encoded and sent")
EVT_REJECTED = NotificationEvent("EVT_REJECTED", "Association request rejected") # noqa
EVT_REJECTED = NotificationEvent("EVT_REJECTED", "Association request rejected")
EVT_RELEASED = NotificationEvent("EVT_RELEASED", "Association released")
EVT_REQUESTED = NotificationEvent("EVT_REQUESTED", "Association requested")

Expand Down Expand Up @@ -166,16 +166,16 @@ def __str__(self) -> str:

EVT_ASYNC_OPS = InterventionEvent(
"EVT_ASYNC_OPS", "Asynchronous operations negotiation requested"
) # noqa
)
EVT_SOP_COMMON = InterventionEvent(
"EVT_SOP_COMMON", "SOP class common extended negotiation requested"
) # noqa
)
EVT_SOP_EXTENDED = InterventionEvent(
"EVT_SOP_EXTENDED", "SOP class extended negotiation requested"
) # noqa
)
EVT_USER_ID = InterventionEvent(
"EVT_USER_ID", "User identity negotiation requested"
) # noqa
)
EVT_C_ECHO = InterventionEvent("EVT_C_ECHO", "C-ECHO request received")
EVT_C_FIND = InterventionEvent("EVT_C_FIND", "C-FIND request received")
EVT_C_GET = InterventionEvent("EVT_C_GET", "C-GET request received")
Expand All @@ -186,7 +186,7 @@ def __str__(self) -> str:
EVT_N_DELETE = InterventionEvent("EVT_N_DELETE", "N-DELETE request received")
EVT_N_EVENT_REPORT = InterventionEvent(
"EVT_N_EVENT_REPORT", "N-EVENT-REPORT request received"
) # noqa
)
EVT_N_GET = InterventionEvent("EVT_N_GET", "N-GET request received")
EVT_N_SET = InterventionEvent("EVT_N_SET", "N-SET request received")

Expand Down
2 changes: 1 addition & 1 deletion pynetdicom/pdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ def __str__(self) -> str:

return s

def _wrap_generate_items(self, bytestream: bytes) -> _PDVItem: # type: ignore
def _wrap_generate_items(self, bytestream: bytes) -> _PDVItem: # type: ignore[override]
"""Return a list of PDV Items generated from `bytestream`.

Parameters
Expand Down
16 changes: 8 additions & 8 deletions pynetdicom/pdu_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ def __str__(self) -> str:
"Abstract Syntax Sub-item",
f" Item type: 0x{self.item_type:02X}",
f" Item length: {self.item_length} bytes",
f" Syntax name: ={self.abstract_syntax.name}", # type: ignore
f" Syntax name: ={self.abstract_syntax.name}", # type: ignore[union-attr]
]

return "\n".join(s)
Expand Down Expand Up @@ -2311,7 +2311,7 @@ def __str__(self) -> str:
s += f" Item type: 0x{self.item_type:02X}\n"
s += f" Item length: {self.item_length} bytes\n"
s += f" UID length: {self.uid_length} bytes\n"
s += f" SOP Class UID: {self.uid.name}\n" # type: ignore
s += f" SOP Class UID: {self.uid.name}\n" # type: ignore[union-attr]
s += f" SCU Role: {self.scu}\n"
s += f" SCP Role: {self.scp}\n"

Expand Down Expand Up @@ -2521,7 +2521,7 @@ def __str__(self) -> str:
s += f" Item type: 0x{self.item_type:02X}\n"
s += f" Item length: {self.item_length} bytes\n"
s += f" SOP class UID length: {self.sop_class_uid_length} bytes\n"
s += f" SOP class: ={self.sop_class_uid.name}\n" # type: ignore
s += f" SOP class: ={self.sop_class_uid.name}\n" # type: ignore[union-attr]
s += (
f" Service class application information: "
f"{self.service_class_application_information!r}\n"
Expand Down Expand Up @@ -2732,7 +2732,7 @@ def _encoders(self) -> Any:
]

@staticmethod
def _generate_items(bytestream: bytes) -> Iterator[UID]: # type: ignore
def _generate_items(bytestream: bytes) -> Iterator[UID]: # type: ignore[override]
"""Yield Related General SOP Class UIDs from `bytestream`.

Parameters
Expand Down Expand Up @@ -2889,9 +2889,9 @@ def __str__(self) -> str:
f" Item type: 0x{self.item_type:02X}",
f" Item length: {self.item_length} bytes",
f" SOP class UID length: {self.sop_class_uid_length} bytes",
f" SOP class: ={self.sop_class_uid.name}", # type: ignore
f" SOP class: ={self.sop_class_uid.name}", # type: ignore[union-attr]
f" Service class UID length: {self.service_class_uid_length} bytes",
f" Service class UID: ={self.service_class_uid.name}", # type: ignore
f" Service class UID: ={self.service_class_uid.name}", # type: ignore[union-attr]
f" Related general SOP class ID length: "
f"{self.related_general_sop_class_identification_length} bytes",
" Related general SOP class ID(s):",
Expand All @@ -2905,7 +2905,7 @@ def __str__(self) -> str:

return "\n".join(s)

def _wrap_generate_items(self, b: bytes) -> list[UID]: # type: ignore
def _wrap_generate_items(self, b: bytes) -> list[UID]: # type: ignore[override]
"""Return a list of UID items generated from `bytestream`."""
return list(self._generate_items(b))

Expand Down Expand Up @@ -3444,7 +3444,7 @@ def message_control_header_byte(self) -> str:
def __str__(self) -> str:
"""Return a string representation of the Item."""
pdv_samples = " ".join(
f"0x{b:02X}" for b in self.presentation_data_value[:10] # type: ignore
f"0x{b:02X}" for b in self.presentation_data_value[:10] # type: ignore[index]
)
s = [
"Presentation Value Data Item",
Expand Down
2 changes: 1 addition & 1 deletion pynetdicom/presentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ def build_context(

context = PresentationContext()
context.abstract_syntax = abstract_syntax
context.transfer_syntax = transfer_syntax # type: ignore
context.transfer_syntax = transfer_syntax # type: ignore[assignment]

return context

Expand Down
8 changes: 4 additions & 4 deletions pynetdicom/service_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _c_find_scp(self, req: C_FIND, context: "PresentationContext") -> None:
LOGGER.error(
"\nTraceback (most recent call last):\n"
+ "".join(traceback.format_tb(exc[2]))
+ f"{exc[0].__name__}: {exc[1]}" # type: ignore
+ f"{exc[0].__name__}: {exc[1]}" # type: ignore[arg-type]
)
rsp_status = 0xC311
dataset = None
Expand Down Expand Up @@ -1772,7 +1772,7 @@ def _add_failed_instance(ds: Dataset) -> None:
LOGGER.error(
"\nTraceback (most recent call last):\n"
+ "".join(traceback.format_tb(exc[2]))
+ f"{exc[0].__name__}: {exc[1]}" # type: ignore
+ f"{exc[0].__name__}: {exc[1]}" # type: ignore[arg-type]
)
rsp_status = 0xC411
dataset = None
Expand Down Expand Up @@ -2157,7 +2157,7 @@ def _move_scp(self, req: C_MOVE, context: "PresentationContext") -> None:
kwargs.update(destination[2])

store_assoc = self.ae.associate(
destination[0], destination[1], **kwargs # type: ignore
destination[0], destination[1], **kwargs # type: ignore[arg-type]
)

if not ctx.success:
Expand Down Expand Up @@ -2199,7 +2199,7 @@ def _add_failed_instance(ds: Dataset) -> None:
LOGGER.error(
"\nTraceback (most recent call last):\n"
+ "".join(traceback.format_tb(exc[2]))
+ f"{exc[0].__name__}: {exc[1]}" # type: ignore
+ f"{exc[0].__name__}: {exc[1]}" # type: ignore[union-attr]
)
rsp_status = 0xC511
dataset = None
Expand Down
2 changes: 1 addition & 1 deletion pynetdicom/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def set_timer_resolution(resolution: float | None) -> Iterator[None]:
None
"""
if HAVE_CTYPES and sys.platform == "win32" and resolution is not None:
dll = ctypes.WinDLL("NTDLL.DLL") # type: ignore
dll = ctypes.WinDLL("NTDLL.DLL") # type: ignore[attr-defined]

minimum = ctypes.c_ulong() # Minimum delay allowed
maximum = ctypes.c_ulong() # Maximum delay allowed
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ extend-select = [
"PIE",
"PYI",
"FLY",
"PGH",
"UP",
]
ignore = [
Expand Down
Loading