csa-header 1.0.0__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. {csa_header-1.0.0 → csa_header-1.0.2}/CHANGELOG.md +19 -1
  2. {csa_header-1.0.0 → csa_header-1.0.2}/PKG-INFO +1 -1
  3. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/__about__.py +1 -1
  4. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/ascii/header.py +1 -1
  5. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/header.py +1 -2
  6. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/unpacker.py +1 -1
  7. {csa_header-1.0.0 → csa_header-1.0.2}/pyproject.toml +2 -0
  8. {csa_header-1.0.0 → csa_header-1.0.2}/tests/test_header.py +6 -8
  9. {csa_header-1.0.0 → csa_header-1.0.2}/tests/test_unpacker.py +1 -1
  10. {csa_header-1.0.0 → csa_header-1.0.2}/.gitignore +0 -0
  11. {csa_header-1.0.0 → csa_header-1.0.2}/CODE_OF_CONDUCT.md +0 -0
  12. {csa_header-1.0.0 → csa_header-1.0.2}/CONTRIBUTING.md +0 -0
  13. {csa_header-1.0.0 → csa_header-1.0.2}/LICENSE.txt +0 -0
  14. {csa_header-1.0.0 → csa_header-1.0.2}/README.md +0 -0
  15. {csa_header-1.0.0 → csa_header-1.0.2}/SECURITY.md +0 -0
  16. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/__init__.py +0 -0
  17. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/ascii/__init__.py +0 -0
  18. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/ascii/ascconv.py +0 -0
  19. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/ascii/messages.py +0 -0
  20. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/exceptions.py +0 -0
  21. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/messages.py +0 -0
  22. {csa_header-1.0.0 → csa_header-1.0.2}/csa_header/utils.py +0 -0
  23. {csa_header-1.0.0 → csa_header-1.0.2}/examples/README.md +0 -0
  24. {csa_header-1.0.0 → csa_header-1.0.2}/examples/nibabel_integration.py +0 -0
  25. {csa_header-1.0.0 → csa_header-1.0.2}/tests/__init__.py +0 -0
  26. {csa_header-1.0.0 → csa_header-1.0.2}/tests/ascii/__init__.py +0 -0
  27. {csa_header-1.0.0 → csa_header-1.0.2}/tests/ascii/fixtures.py +0 -0
  28. {csa_header-1.0.0 → csa_header-1.0.2}/tests/ascii/test_ascconv_parsing.py +0 -0
  29. {csa_header-1.0.0 → csa_header-1.0.2}/tests/ascii/test_ascconv_sample.py +0 -0
  30. {csa_header-1.0.0 → csa_header-1.0.2}/tests/ascii/test_header.py +0 -0
  31. {csa_header-1.0.0 → csa_header-1.0.2}/tests/benchmarks/__init__.py +0 -0
  32. {csa_header-1.0.0 → csa_header-1.0.2}/tests/benchmarks/bench_parsing.py +0 -0
  33. {csa_header-1.0.0 → csa_header-1.0.2}/tests/files/__init__.py +0 -0
  34. {csa_header-1.0.0 → csa_header-1.0.2}/tests/files/ascconv_sample.txt +0 -0
  35. {csa_header-1.0.0 → csa_header-1.0.2}/tests/files/dwi_image_header_info +0 -0
  36. {csa_header-1.0.0 → csa_header-1.0.2}/tests/files/e11_series_header_info +0 -0
  37. {csa_header-1.0.0 → csa_header-1.0.2}/tests/files/rsfmri_series_header_info +0 -0
  38. {csa_header-1.0.0 → csa_header-1.0.2}/tests/fixtures.py +0 -0
@@ -7,8 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.1] - 2025-10-28
11
+
12
+ ### Fixed
13
+ - **Python 3.9 compatibility**: Added `from __future__ import annotations` to ensure compatibility with Python 3.9
14
+ - **Linting violations**: Resolved 11 ruff violations from pre-commit.ci
15
+ - Removed unused imports (`Iterable`, `pytest`)
16
+ - Fixed unused variable assignments (F841, B007)
17
+ - Replaced inefficient list slicing with `next(iter())` (RUF015)
18
+ - Replaced blind exception catching with specific exception types (B017)
19
+ - **Code style**: Auto-fixed quote style consistency (Q000) and `__slots__` sorting (RUF023)
20
+
10
21
  ### Changed
11
- - **CODE_OF_CONDUCT.md**: Replaced Contributor Covenant v2.1 with a community-focused code of conduct inspired by the NIPY community standards. The new version uses friendlier, less legalistic language while maintaining clear guidelines for respectful collaboration.
22
+ - **Performance**: Added `__slots__` to classes for memory efficiency and faster attribute access
23
+ - **Code quality**: Comprehensive refactoring to improve maintainability
24
+ - Better error handling with specific exception types
25
+ - More Pythonic iteration patterns
26
+ - Cleaner variable naming conventions
27
+ - **Code of conduct**: Replaced Contributor Covenant v2.1 with a community-focused code of conduct inspired by the NIPY community standards
28
+ - **Examples**: Added per-file-ignores for `examples/**/*` to allow simpler, more readable code patterns
12
29
 
13
30
  ## [1.0.0] - 2025-10-28
14
31
 
@@ -160,5 +177,6 @@ Potential features for future releases:
160
177
 
161
178
  ---
162
179
 
180
+ [1.0.1]: https://github.com/open-dicom/csa_header/compare/v1.0.0...v1.0.1
163
181
  [1.0.0]: https://github.com/open-dicom/csa_header/compare/v0.0.1...v1.0.0
164
182
  [0.0.1]: https://github.com/open-dicom/csa_header/releases/tag/v0.0.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csa_header
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: Parse Siemens CSA header information
5
5
  Project-URL: Documentation, https://github.com/open-dicom/csa_header#readme
6
6
  Project-URL: Issues, https://github.com/open-dicom/csa_header/issues
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2023-present Zvi Baratz <z.baratz@gmail.com>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "1.0.0"
4
+ __version__ = "1.0.2"
@@ -14,7 +14,7 @@ class CsaAsciiHeader:
14
14
  returned by `pydicom <https://github.com/pydicom/pydicom>`_ as bytes.
15
15
  """
16
16
 
17
- __slots__ = ('_header', '_parsed')
17
+ __slots__ = ("_header", "_parsed")
18
18
 
19
19
  #: The header's ASCII-based character encoding.
20
20
  ENCODING = "ISO-8859-1"
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from collections.abc import Iterable
6
5
  from typing import Any
7
6
 
8
7
  from csa_header.ascii import CsaAsciiHeader
@@ -26,7 +25,7 @@ class CsaHeader:
26
25
  https://github.com/icometrix/dicom2nifti/blob/6722420a7673d36437e4358ce3cb2a7c77c91820/dicom2nifti/convert_siemens.py#L342
27
26
  """
28
27
 
29
- __slots__ = ('raw', 'header_size', '_first_tag_n_items', '_csa_type')
28
+ __slots__ = ("_csa_type", "_first_tag_n_items", "header_size", "raw")
30
29
 
31
30
  CSA_TYPE_1: int = 1
32
31
  CSA_TYPE_2: int = 2
@@ -38,7 +38,7 @@ class Unpacker:
38
38
  7
39
39
  """
40
40
 
41
- __slots__ = ('buffer', 'pointer', 'endian', '_cache')
41
+ __slots__ = ("_cache", "buffer", "endian", "pointer")
42
42
 
43
43
  def __init__(self, buffer: bytes, pointer: int = 0, endian: str | None = None):
44
44
  """
@@ -173,6 +173,8 @@ ban-relative-imports = "all"
173
173
  [tool.ruff.lint.per-file-ignores]
174
174
  # Tests can use magic values, assertions, and relative imports
175
175
  "tests/**/*" = ["PLR2004", "S101", "TID252"]
176
+ # Examples can use simpler patterns for clarity
177
+ "examples/**/*" = ["EM101", "EM102", "PLR2004", "PLC0415"]
176
178
 
177
179
  [tool.pytest.ini_options]
178
180
  testpaths = [
@@ -5,8 +5,6 @@ from __future__ import annotations
5
5
  import struct
6
6
  from unittest import TestCase
7
7
 
8
- import pytest
9
-
10
8
  from csa_header.exceptions import CsaReadError
11
9
  from csa_header.header import CsaHeader
12
10
  from csa_header.unpacker import Unpacker
@@ -500,7 +498,7 @@ class CsaHeaderParseTagTestCase(TestCase):
500
498
 
501
499
  # First tag (index 1 in the code, but we pass 1 as i_tag)
502
500
  self.assertIsNone(csa._first_tag_n_items)
503
- tag = csa.parse_tag(unpacker, i_tag=1)
501
+ _ = csa.parse_tag(unpacker, i_tag=1)
504
502
  self.assertEqual(csa._first_tag_n_items, 42)
505
503
 
506
504
 
@@ -543,7 +541,7 @@ class CsaHeaderReadTestCase(TestCase):
543
541
  result = csa.read()
544
542
 
545
543
  # Check first tag
546
- first_tag_name = list(result.keys())[0]
544
+ first_tag_name = next(iter(result.keys()))
547
545
  tag = result[first_tag_name]
548
546
 
549
547
  # Tag should have these keys
@@ -612,7 +610,7 @@ class CsaHeaderReadTestCase(TestCase):
612
610
  result = csa.read()
613
611
 
614
612
  # Some tags have None values
615
- for tag_name, tag_data in result.items():
613
+ for _tag_name, tag_data in result.items():
616
614
  if tag_data["value"] is None:
617
615
  # Just verify it doesn't crash
618
616
  self.assertIsNone(tag_data["value"])
@@ -729,7 +727,7 @@ class CsaHeaderErrorHandlingTestCase(TestCase):
729
727
  def test_read_with_empty_header_raises_error(self):
730
728
  """Test that reading empty header raises appropriate error."""
731
729
  csa = CsaHeader(b"")
732
- with self.assertRaises(Exception):
730
+ with self.assertRaises((CsaReadError, struct.error)):
733
731
  csa.read()
734
732
 
735
733
  def test_read_with_truncated_header(self):
@@ -738,7 +736,7 @@ class CsaHeaderErrorHandlingTestCase(TestCase):
738
736
  raw = b"SV10\x01\x00\x00\x00" # Only 8 bytes
739
737
  csa = CsaHeader(raw)
740
738
 
741
- with self.assertRaises(Exception):
739
+ with self.assertRaises((CsaReadError, struct.error)):
742
740
  csa.read()
743
741
 
744
742
  def test_read_with_invalid_n_tags(self):
@@ -747,7 +745,7 @@ class CsaHeaderErrorHandlingTestCase(TestCase):
747
745
  raw = b"SV10\x04\x03\x02\x01" + struct.pack("<2I", 10000, 0) + b"\x00" * 100
748
746
  csa = CsaHeader(raw)
749
747
 
750
- with self.assertRaises(Exception):
748
+ with self.assertRaises((CsaReadError, struct.error)):
751
749
  csa.read()
752
750
 
753
751
  def test_malformed_tag_name(self):
@@ -356,7 +356,7 @@ class UnpackerCachingTestCase(TestCase):
356
356
  # First call should populate cache
357
357
  for _ in range(100):
358
358
  unpacker = Unpacker(buffer, endian="<")
359
- for i in range(100):
359
+ for _i in range(100):
360
360
  unpacker.unpack("i")
361
361
  # Cache should remain size 2 (with endian prefix)
362
362
  self.assertEqual(len(unpacker._cache), 2)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes