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

BUG: Fix conversion from 1 to LA #2175

Merged
merged 1 commit into from
Sep 9, 2023
Merged

Conversation

pubpub-zz
Copy link
Collaborator

@pubpub-zz pubpub-zz commented Sep 7, 2023

Closes #2165
Closes #2176

@pubpub-zz
Copy link
Collaborator Author

@MartinThoma
During pre-commit I've got the following issues reported:

pypdf\filters.py:795:5: C901 _xobj_to_image is too complex (55 > 54)
pypdf\filters.py:795:5: PLR0915 Too many statements (178 > 176)
tests\test_writer.py:1607:9: S603 subprocess call: check for execution of untrusted input
Found 4 errors (1 fixed, 3 remaining).

@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (05f2a65) 94.25% compared to head (c0aa032) 94.25%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2175   +/-   ##
=======================================
  Coverage   94.25%   94.25%           
=======================================
  Files          42       42           
  Lines        7556     7558    +2     
  Branches     1487     1488    +1     
=======================================
+ Hits         7122     7124    +2     
  Misses        266      266           
  Partials      168      168           
Files Changed Coverage Δ
pypdf/filters.py 94.54% <100.00%> (+0.02%) ⬆️

☔ View full report in Codecov by Sentry.

📢 Have feedback on the report? Share it here.

@pubpub-zz
Copy link
Collaborator Author

@MartinThoma
this PR is all yours. Can you fix this issue ?

@stefan6419846
Copy link
Collaborator

I cannot see the third violation in CI (this should be related to the subprocess call for the watermark rendering, where there is an non-fixable error raised regardless of how the call is made).

For the other issues, see #2108. You should either refactor the code to reduce complexity or be able to justify why the increased complexity is necessary and cannot be avoided.

@pubpub-zz
Copy link
Collaborator Author

I cannot see the third violation in CI (this should be related to the subprocess call for the watermark rendering, where there is an non-fixable error raised regardless of how the call is made).

For the other issues, see #2108. You should either refactor the code to reduce complexity or be able to justify why the increased complexity is necessary and cannot be avoided.

the refactoring required is too important to be part of this PR : this will require an idenpendant PR. about the subprocess it should be part of an independant PR too for traceeability

@stefan6419846
Copy link
Collaborator

You are not asked to do the refactoring of the complete code, but only for the corresponding section. I do not really see why this cannot be part of this PR - the chosen approach is to slowly refactor the sections which are changed anyway to not do everything at once. And as you are working on the corresponding code section, you already show that you understand enough of it to be able to safely refactor it, assuming that our test coverage is sufficient.

And as already mentioned: The subprocess violation you see should not even occur and cannot be seen in the CI style checks, as it should be ignored due to the noqa marker in the correspondig line already. If you experience issues on your personal device with pre-commit stuff, there seems to be some issue with your setup or with the pre-commit handling (where I do not have any real knowledge about).

@MartinThoma
Copy link
Member

The two style issues we currently see are

pypdf/filters.py:795:5: C901 `_xobj_to_image` is too complex (55 > 54)
pypdf/filters.py:795:5: PLR0915 Too many statements (178 > 176)

I'll check how we can change that :-)

@MartinThoma MartinThoma changed the title BUG: fix convertion from 1 to LA BUG: Fix conversion from 1 to LA Sep 9, 2023
@MartinThoma MartinThoma merged commit 5bfbae7 into py-pdf:main Sep 9, 2023
13 of 14 checks passed
@MartinThoma
Copy link
Member

Good work @pubpub-zz 👍

@MartinThoma
Copy link
Member

I like that the PR is clean / minimal. It was a good decision to not include refactoring in it, as that would have made the review way more complex. I'll take care of that now

@stefan6419846
Copy link
Collaborator

This probably is a matter of taste: In general, projects prefer the current contributor to fix all issues introduced with the current PR from what I have seen in the past (my GitHub activity is non-representative here). Maybe I am a bit opinionated about this as well due to doing a lot of code quality stuff.

In the end, it is up to you as the maintainer to decide on how you handle this, as long as this is a consistent behaviour which is applied equally to all changes.

MartinThoma added a commit that referenced this pull request Sep 10, 2023
## What's new

### Security (SEC)
-  Infinite recursion caused by IndirectObject clone (#2156)

### New Features (ENH)
-  Ease access to ViewerPreferences (#2144)

### Bug Fixes (BUG)
-  catch the case where w[0] is an IndirectObject instead of an int (#2154)
-  Cope with indirect objects in filters and remove deprecated code (#2177)
-  Cope with extra space (#2151)
-  Merge pages without resources (#2150)
-  getcontents() shall return None if contents is NullObject (#2161)
-  Fix conversion from 1 to LA (#2175)
-  Accept tabs in cmaps (#2174)

### Robustness (ROB)
-  Accept XYZ with no arguments (#2178)

[Full Changelog](3.15.5...3.16.0)
@MartinThoma
Copy link
Member

Typically, I would agree that issues should be fixed within the PR. However, there are some exceptions:

  • Value trade-off: If the value added by the PR is bigger than the issue it introduced, I don't want to block the PR.
  • PR readability: I like refactorings to be in separate PRs as it makes them so much easier to understand.

@pubpub-zz pubpub-zz deleted the iss2165 branch August 9, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants