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

PyPDF2 2.0 Changes #859

Merged
merged 20 commits into from May 24, 2022
Merged

PyPDF2 2.0 Changes #859

merged 20 commits into from May 24, 2022

Conversation

MartinThoma
Copy link
Member

This PR should probably be merged with a merge-commit, not a squashing commit.

The PR shows the current progress towards the 2.0.0 release. There are individual PRs going into the dev-2.0.0 branch, e.g. #854

Most importantly, the means Python 2.7 no longer needs to get supported
* All of them are removed from the package distributions
* Scripts is additionally moved to the cpdf project
* Sample_Code is moved to the docs
PdfFileReader and PdfFileMerger no longer have the `overwriteWarnings`.
The new behavior is `overwriteWarnings=False`.

Additionally, PyPDF2.utils.formatWarning was removed
It's expected that this is a more sensible default for most users.
As support for Python 3.5 and lower was dropped, we can use more modern syntax
@MartinThoma MartinThoma changed the title PyPDF 2.0 Changes PyPDF2 2.0 Changes May 5, 2022
@codecov
Copy link

codecov bot commented May 5, 2022

Codecov Report

Merging #859 (e38b23d) into main (f3cb316) will decrease coverage by 2.51%.
The diff coverage is 81.11%.

❗ Current head e38b23d differs from pull request most recent head 3729af0. Consider uploading reports for the commit 3729af0 to get more accurate results

@@            Coverage Diff             @@
##             main     #859      +/-   ##
==========================================
- Coverage   82.47%   79.96%   -2.52%     
==========================================
  Files          16       16              
  Lines        3777     4187     +410     
  Branches      802      813      +11     
==========================================
+ Hits         3115     3348     +233     
- Misses        495      664     +169     
- Partials      167      175       +8     
Impacted Files Coverage Δ
PyPDF2/xmp.py 51.63% <51.47%> (+1.35%) ⬆️
PyPDF2/_merger.py 65.51% <72.36%> (ø)
PyPDF2/_writer.py 78.90% <73.10%> (-9.85%) ⬇️
PyPDF2/_page.py 80.19% <83.58%> (+1.07%) ⬆️
PyPDF2/_reader.py 79.54% <84.87%> (-1.67%) ⬇️
PyPDF2/generic.py 84.24% <87.71%> (-1.57%) ⬇️
PyPDF2/filters.py 75.00% <88.34%> (-2.53%) ⬇️
PyPDF2/_utils.py 90.99% <90.99%> (ø)
PyPDF2/_security.py 94.66% <94.44%> (-1.83%) ⬇️
PyPDF2/__init__.py 100.00% <100.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3cb316...3729af0. Read the comment docs.

@MartinThoma MartinThoma added this to the PyPDF2 version 2.0.0 milestone May 5, 2022
pubpub-zz and others added 4 commits May 7, 2022 08:44
In case of invalid extract stream data looking for endstream

Closes #301
This PR uses 4 ways to disable checks by mypy:

*  74x `typing.cast`: Has no effect on the running code, just on mypy
* 161x `typing.Any`: If we tell mypy that a parameter / variable can have any possible type, mypy cannot check anything.
*  82x `# type: ignore`
*  36x `assert foo is not None`: This can have an effect in running code and should only be used if mypy fails to understand that foo is guaranteed not to be None

Those are especially necessary for `.getObject()` calls. If possible, they
should be removed.

`cast` is preferrable over `# type: ignore` as it gives more information. `assert` should only be used in rare cases.

Uncertainties:

* `ByteStringObject` vs `TextStringObject`, e.g. for `_authenticateUserPassword` and the functions in `_security`
* `ContentStream`: I have no clue what type the stream argument should have

Details:

* utils.ConvertFunctionsToVirtualList -> _VirtualList 
* Typeguard was used to verify that the annotated types are correct. There are
  still some cases where Typeguard fails, but the reason might be that
  Typeguard does not consider inheritance.
* BUG: Potential None attribute access in _reader.getDestinationPageNumber
* BUG: _security._alg33_1 : Adding str and bytes argument
* STY: Fix typo 'test_get_destination_age_number'
* BUG: Field.additionalActions was missing a return statement
MasterOdin and others added 8 commits May 11, 2022 10:03
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
See #863

Co-authored-by: Martin Thoma <info@martin-thoma.de>
This is important for some PyPDF2 developers development workflows.
It allows them to compare changes more easily.

Additionally, some imports were moved from function-level to module-level.

See #865 (comment)

Co-authored-by: pubpub-zz <4083478+pubpub-zz@users.noreply.github.com>
This allows us to have a simpler user interface for page transformations
Add stacklevel=2 to deprecation warnings
This is `git merge main -s ours`
@MartinThoma MartinThoma merged commit dad3bc8 into main May 24, 2022
@MartinThoma MartinThoma mentioned this pull request May 24, 2022
@MartinThoma MartinThoma deleted the 2.0.0-dev branch May 26, 2022 08:13
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.

None yet

3 participants