Skip to content

get_content_type as property, def_context_type from device_info — v0.3.0 #75

Merged
sca075 merged 2 commits intomainfrom
dev
Mar 14, 2026
Merged

get_content_type as property, def_context_type from device_info — v0.3.0 #75
sca075 merged 2 commits intomainfrom
dev

Conversation

@sca075
Copy link
Copy Markdown
Owner

@sca075 sca075 commented Mar 14, 2026

  • CameraShared.get_content_type() converted to @Property (no parentheses needed)
  • update_shared_data now reads 'def_context_type' from device_info to initialise
    image format via set_content_type() — no manual call required after init
  • utils.py match statement updated to use property form (no parentheses)
  • Bump version 0.3.0b2 → 0.3.0 stable

Summary by CodeRabbit

  • Releases

    • Version bumped to 0.3.0 (stable release)
  • Refactor

    • Updated image content-type handling during shared-data initialization
  • Bug Fixes

    • Addressed content-type access change that may affect automatic image binary conversion; verify image outputs for JPEG/PNG/PIL formats
  • Tests

    • Added unit tests for content-type handling and new performance profiling utilities in the test suite

…ice_info — v0.3.0

- CameraShared.get_content_type() converted to @Property (no parentheses needed)
- update_shared_data now reads 'def_context_type' from device_info to initialise
  image format via set_content_type() — no manual call required after init
- utils.py match statement updated to use property form (no parentheses)
- tests/test_shared_attributes.py assertions updated to property access
- tests/test.py device_info updated with 'def_context_type': 'png', manual
  set_content_type() call removed
- Bump version 0.3.0b2 → 0.3.0 stable
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 14, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Converted CameraShared.get_content_type from a method to a read-only property, updated its call sites, wired device_info to set content type during shared-data initialization, bumped package version to 0.3.0, and added/updated tests and a performance profiler in tests.

Changes

Cohort / File(s) Summary
Config: CameraShared
SCR/valetudo_map_parser/config/shared.py
Replaced def get_content_type(self) -> str with a @property read-only get_content_type. Adjusted set_content_type docstring. update_shared_data now calls set_content_type using device_info["def_context_type"] (default "pil").
Utils: binary conversion
SCR/valetudo_map_parser/config/utils.py
Switched _convert_to_binary to access get_content_type as a property (self.shared.get_content_type) instead of calling it. This changes branching behavior for content-type-specific conversions (may prevent JPEG/PNG/PIL conversions if callers weren't updated).
Tests: profiling & shared-attribute tests
tests/test.py, tests/test_shared_attributes.py
Added PerformanceProfiler with memory/CPU profiling and reporting in tests/test.py. Modified test constants and device payload (added obstacle_link_* and def_context_type), enabled PIL show, reduced FRAME_COUNT. Added tests/test_shared_attributes.py with fixture shared() and TestSetGetContentType test cases covering key and MIME inputs, round-trips, invalid/default behavior. Adjusted trims in test data and added content-type logging.
Release
pyproject.toml
Bumped package version from 0.3.0b2 to 0.3.0.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through code with whiskers bright,
Properties now gleam in morning light,
Tests and profilers dance in a row,
Content types set where device winds blow,
Version patched — onward we go! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: converting get_content_type to a property and reading def_context_type from device_info during initialization, with version bump to v0.3.0.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
SCR/valetudo_map_parser/config/utils.py (1)

1013-1017: ⚠️ Potential issue | 🔴 Critical

Invalid Pillow format: format="PIL" is not a supported save format.

Image.save(format="PIL") will raise a KeyError at runtime — Pillow does not recognize "PIL" as a valid format. The supported formats are "PNG", "JPEG", "TIFF", "GIF", "BMP", etc.

Additionally, the docstring says "PNG bytes" but the code uses format="PIL". If the intent is to serialize a PIL Image for reconstruction, use pickle or correct the format to "PNG". Verify the intended behavior and fix accordingly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@SCR/valetudo_map_parser/config/utils.py` around lines 1013 - 1017, The
pil_to_pil_bytes function is using an invalid Pillow format ("PIL") and its
docstring claims PNG; change the save call to use a real format like "PNG" and
update the docstring accordingly (e.g., pil_img.save(buf, format="PNG",
compress_level=compress_level)) so it returns PNG bytes, or if the intent was
full Python object serialization instead, replace the implementation with
pickle.dumps(pil_img) and adjust the docstring; reference the pil_to_pil_bytes
function to make this correction.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@SCR/valetudo_map_parser/config/shared.py`:
- Around line 170-173: The test calls the property get_content_type incorrectly
as a method; update the test in tests/test_shared_attributes.py (around the
assertion on line 100) to access the property without parentheses (use
shared.get_content_type instead of shared.get_content_type()) so it matches the
`@property` on the get_content_type attribute in shared.py and avoids the
TypeError.
- Around line 397-399: Fix the typo when reading the default content type from
device_info: change the key used in the device_info.get call inside the
instance.set_content_type call from "def_context_type" to "def_content_type" so
it matches the rest of the codebase (e.g., ATTR_CONTENT_TYPE, set_content_type,
get_content_type) and correctly supplies the default content type to
instance.set_content_type.

---

Outside diff comments:
In `@SCR/valetudo_map_parser/config/utils.py`:
- Around line 1013-1017: The pil_to_pil_bytes function is using an invalid
Pillow format ("PIL") and its docstring claims PNG; change the save call to use
a real format like "PNG" and update the docstring accordingly (e.g.,
pil_img.save(buf, format="PNG", compress_level=compress_level)) so it returns
PNG bytes, or if the intent was full Python object serialization instead,
replace the implementation with pickle.dumps(pil_img) and adjust the docstring;
reference the pil_to_pil_bytes function to make this correction.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5fdd3a9a-1d41-4181-801f-3393b98eab6d

📥 Commits

Reviewing files that changed from the base of the PR and between 7649210 and fec6133.

📒 Files selected for processing (3)
  • SCR/valetudo_map_parser/config/shared.py
  • SCR/valetudo_map_parser/config/utils.py
  • pyproject.toml

@sca075 sca075 merged commit 7057a1f into main Mar 14, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant