MAINT: Use placeholder-based approach for logger_warning#3746
MAINT: Use placeholder-based approach for logger_warning#3746MestreY0d4-Uninter wants to merge 9 commits intopy-pdf:mainfrom
Conversation
stefan6419846
left a comment
There was a problem hiding this comment.
Thanks for the PR. Please have a look at the test failures and the inline comments.
656bf4e to
cbe7817
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3746 +/- ##
==========================================
+ Coverage 97.59% 97.61% +0.02%
==========================================
Files 55 55
Lines 10225 10231 +6
Branches 1877 1879 +2
==========================================
+ Hits 9979 9987 +8
+ Misses 141 140 -1
+ Partials 105 104 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ee5ada3 to
210a648
Compare
|
Thanks for the follow-up review, @stefan6419846. I addressed the latest comments in the current branch (
Validation:
Ready for re-review. |
|
Re-review requested — CI is green. I validated the logger_warning/logger_error alignment, caplog usage, missed call sites, and the coverage patch. Local test run: test_utils, 111 passed. |
|
Addressed the two remaining current review threads in
Validation:
Ready for re-review. |
|
@stefan6419846 I replied to the remaining current thread and marked it resolved. The latest head is |
| f"Length of text {text} exceeds maximum length ({max_length}) of field, input truncated.", | ||
| __name__ | ||
| logger_warning( | ||
| "Length of text %(text)s exceeds maximum length (%(max_length)d) " |
There was a problem hiding this comment.
While it is valid syntax, please use proper grouping to make such cases more readable, id est something like this:
logger_warning(
(
"Length of text %(text)s exceeds maximum length (%(max_length)d) "
"of field, input truncated."
),
source=__name__,
text=text,
max_length=max_length
)There was a problem hiding this comment.
Please adjust the remaining similar sections as well (spotted at least one instance in _reader.py).
This is the second PR for py-pdf#3384 and covers logger_warning. It updates logger_warning to support placeholder-based logging, converts logger_warning call sites away from f-strings, and adds regression coverage for placeholder and no-placeholder cases.
69edb5a to
64a50e3
Compare
| f"found {actual_count} objects within Object({object_number},{generation_number})" | ||
| f" whereas {obj.get('/N')} expected", | ||
| __name__, | ||
| "found %(actual_count)d objects within " |
There was a problem hiding this comment.
This should be updated as well, see #3746 (comment).
Summary
This is the follow-up PR for #3384 that covers
logger_warning.It updates
logger_warningto support placeholder-based logging without breaking warning messages that do not interpolate values, and convertslogger_warningcall sites away from f-strings / preformatted warning messages.Changes
logger_warningto acceptmessage, source, **valueslogger_warningcall sites to%(name)s/%(name)rplaceholder stylelogger_warningusageValidation
Local validation completed:
ruff check .python3 -m py_compile pypdf/__init__.py tests/test_utils.py tests/test_text_extraction.py.venv/bin/python -m pytest tests/test_utils.py tests/test_encryption.py::test_aes_decrypt__wrong_padding tests/test_reader.py::test_read_pdf15_xref_stream__size_limit tests/test_reader.py::test_get_object_from_stream__size_limit tests/test_text_extraction.py::test_layout_mode_warnings tests/generic/test_data_structures.py::test_tree_object__cyclic_reference tests/generic/test_image_xobject.py tests/test_filters.py::test_ascii_hex_decode_missing_eod -qNote: a broader local run in this checkout hits missing sample/pdf_cache artifacts that are environment-specific here; the focused warning-related coverage above passed, and CI will exercise the full project matrix.
Related issue
Fixes #3384
AI assistance
Created with AI coding assistance via Hermes Agent.