Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce ruff rules (RUF) #290

Merged
merged 3 commits into from
Jun 15, 2024
Merged
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
10 changes: 5 additions & 5 deletions src/highdicom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
from highdicom.version import __version__

__all__ = [
'LUT',
'UID',
'VOILUT',
'AlgorithmIdentificationSequence',
'AnatomicalOrientationTypeValues',
'ContentCreatorIdentificationCodeSequence',
Expand All @@ -66,7 +69,6 @@
'DimensionOrganizationTypeValues',
'IssuerOfIdentifier',
'LateralityValues',
'LUT',
'ModalityLUT',
'ModalityLUTTransformation',
'PaletteColorLUT',
Expand All @@ -85,19 +87,18 @@
'PresentationLUTTransformation',
'ReferencedImageSequence',
'RescaleTypeValues',
'SOPClass',
'SegmentedPaletteColorLUT',
'SpecimenCollection',
'SpecimenDescription',
'SpecimenPreparationStep',
'SpecimenProcessing',
'SpecimenSampling',
'SpecimenStaining',
'SOPClass',
'UID',
'UniversalEntityIDTypeValues',
'VOILUT',
'VOILUTFunctionValues',
'VOILUTTransformation',
'__version__',
'ann',
'color',
'frame',
Expand All @@ -111,5 +112,4 @@
'spatial',
'sr',
'utils',
'__version__',
]
2 changes: 1 addition & 1 deletion src/highdicom/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def _copy_attribute(
"""
tag = tag_for_keyword(keyword)
if tag is None:
raise ValueError('No tag not found for keyword "{keyword}".')
raise ValueError(f'No tag not found for keyword "{keyword}".')
try:
data_element = dataset[tag]
logger.debug('copied attribute "{}"'.format(keyword))
Expand Down
2 changes: 1 addition & 1 deletion src/highdicom/pr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
'AdvancedBlending',
'AdvancedBlendingPresentationState',
'AnnotationUnitsValues',
'BlendingModeValues',
'BlendingDisplay',
'BlendingDisplayInput',
'BlendingModeValues',
'ColorSoftcopyPresentationState',
'GraphicAnnotation',
'GraphicGroup',
Expand Down
2 changes: 1 addition & 1 deletion src/highdicom/sc/sop.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(
patient_birth_date: Optional[str] = None,
patient_sex: Union[str, PatientSexValues, None] = None,
accession_number: Optional[str] = None,
study_id: str = None,
study_id: Optional[str] = None,
study_date: Optional[Union[str, datetime.date]] = None,
study_time: Optional[Union[str, datetime.time]] = None,
referring_physician_name: Optional[Union[str, PersonName]] = None,
Expand Down
6 changes: 3 additions & 3 deletions src/highdicom/seg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

__all__ = [
'DimensionIndexSequence',
'Segmentation',
'segread',
'SegmentAlgorithmTypeValues',
'SegmentDescription',
'Segmentation',
'SegmentationFractionalTypeValues',
'SegmentationTypeValues',
'SegmentDescription',
'SegmentsOverlapValues',
'SpatialLocationsPreservedValues',
'create_segmentation_pyramid',
'segread',
'utils',
]
2 changes: 1 addition & 1 deletion src/highdicom/sr/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ def from_segmentation(
for frame_number in frame_numbers:
if frame_number < 1 or frame_number > number_of_frames:
raise ValueError(
'Value {frame_number} is not a valid frame number.'
f'Value {frame_number} is not a valid frame number.'
)
frame_index = frame_number - 1
item = segmentation.PerFrameFunctionalGroupsSequence[frame_index]
Expand Down
10 changes: 5 additions & 5 deletions src/highdicom/sr/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,7 @@ def __init__(
algorithm_id: Optional[AlgorithmIdentification] = None,
finding_sites: Optional[Sequence[FindingSite]] = None,
session: Optional[str] = None,
measurements: Sequence[Measurement] = None,
measurements: Optional[Sequence[Measurement]] = None,
qualitative_evaluations: Optional[
Sequence[QualitativeEvaluation]
] = None,
Expand Down Expand Up @@ -2978,7 +2978,7 @@ def __init__(
algorithm_id: Optional[AlgorithmIdentification] = None,
finding_sites: Optional[Sequence[FindingSite]] = None,
session: Optional[str] = None,
measurements: Sequence[Measurement] = None,
measurements: Optional[Sequence[Measurement]] = None,
qualitative_evaluations: Optional[
Sequence[QualitativeEvaluation]
] = None,
Expand Down Expand Up @@ -3088,7 +3088,7 @@ def __init__(
algorithm_id: Optional[AlgorithmIdentification] = None,
finding_sites: Optional[Sequence[FindingSite]] = None,
session: Optional[str] = None,
measurements: Sequence[Measurement] = None,
measurements: Optional[Sequence[Measurement]] = None,
qualitative_evaluations: Optional[
Sequence[QualitativeEvaluation]
] = None,
Expand Down Expand Up @@ -3244,7 +3244,7 @@ def __init__(
algorithm_id: Optional[AlgorithmIdentification] = None,
finding_sites: Optional[Sequence[FindingSite]] = None,
session: Optional[str] = None,
measurements: Sequence[Measurement] = None,
measurements: Optional[Sequence[Measurement]] = None,
qualitative_evaluations: Optional[
Sequence[QualitativeEvaluation]
] = None,
Expand Down Expand Up @@ -3531,7 +3531,7 @@ def __init__(
algorithm_id: Optional[AlgorithmIdentification] = None,
finding_sites: Optional[Sequence[FindingSite]] = None,
session: Optional[str] = None,
measurements: Sequence[Measurement] = None,
measurements: Optional[Sequence[Measurement]] = None,
qualitative_evaluations: Optional[
Sequence[QualitativeEvaluation]
] = None,
Expand Down
2 changes: 1 addition & 1 deletion src/highdicom/sr/value_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _assert_value_type(

"""
if not hasattr(dataset, 'ValueType'):
raise AttributeError('Dataset is not an SR Content Item:\n{dataset}.')
raise AttributeError(f'Dataset is not an SR Content Item:\n{dataset}.')
if not dataset.ValueType == value_type.value:
raise ValueError(
'Dataset is not an SR Content Item with value type '
Expand Down
Loading