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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
304d9ff
DEP: Drop pre-Python 3.6 support (#842)
MartinThoma May 1, 2022
4b069dd
DEP: Remove PyPDF2.pdf module (#844)
MartinThoma May 1, 2022
835b717
DEP: Remove Scripts, Resources, Tests, Sample_Code (#845)
MartinThoma May 1, 2022
e083526
DEP: overwriteWarnings parameter of reader/merger (#846)
MartinThoma May 1, 2022
64f91ee
DEP: Remove merger.OutlinesObject (#847)
MartinThoma May 1, 2022
3c15f61
Change default to strict=False in PdfFileReader/PdfFileMerger (#848)
MartinThoma May 1, 2022
f06375e
MAINT: Use Python 3.6 language features (#849)
MartinThoma May 1, 2022
b580a45
MAINT: Add initial type support with mypy (#853)
MartinThoma May 2, 2022
e48bc6d
ROB: Cope with invalid length in streams (#861)
pubpub-zz May 7, 2022
50e9079
MAINT: Type annotations for all functions/methods (#854)
MartinThoma May 8, 2022
9a9cfee
MAINT: merger.py ➔ _merger.py (#864)
MartinThoma May 8, 2022
96711cc
MAINT: Remove star imports (#865)
MartinThoma May 8, 2022
29b1006
MAINT: Remove unnecessary generics imports (#873)
MasterOdin May 11, 2022
2478309
MAINT: Inline PAGE_RANGE_HELP string (#874)
MasterOdin May 11, 2022
98f72e4
MAINT: Remove IronPython Fallback for zlib (#872)
MasterOdin May 13, 2022
4429066
DEV: Use relative imports (#875)
MartinThoma May 14, 2022
5703b61
MAINT: Explicitly represent transformation matrix (#878)
MartinThoma May 19, 2022
adee9f0
ENH: Add Page.add_transformation (#883)
MartinThoma May 22, 2022
e38b23d
MAINT: Use new PEP8 compliant names (#884)
MartinThoma May 22, 2022
3729af0
Merge main ours (#894)
MartinThoma May 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Expand Up @@ -13,7 +13,7 @@ Replace this: What happened? What were you trying to achieve?

Which environment were you using when you encountered the problem?

```python
```bash
$ python -m platform
# TODO: Your output goes here

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-request.md
Expand Up @@ -15,7 +15,7 @@ Explain briefly what you want to achive.
How would your feature be used? (Remove this if it is not applicable.)

```python
from PyPDF2 import PdfFileReader, PdfFileWriter
from PyPDF2 import PdfReader, PdfWriter

... # your new feature in action!
```
3 changes: 1 addition & 2 deletions .github/workflows/benchmark.yaml
Expand Up @@ -23,15 +23,14 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements (Python 3)
if: matrix.python-version != '2.7'
run: |
pip install -r requirements/ci.txt
- name: Install PyPDF2
run: |
pip install .
- name: Run benchmark
run: |
pytest Tests/bench.py --benchmark-json output.json
pytest tests/bench.py --benchmark-json output.json
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
Expand Down
25 changes: 9 additions & 16 deletions .github/workflows/github-ci.yaml
Expand Up @@ -5,12 +5,12 @@ name: CI

on:
push:
branches: [ main ]
branches: [ main, 2.0.0-dev ]
paths-ignore:
- '**/*.md'
- '**/*.rst'
pull_request:
branches: [ main ]
branches: [ main, 2.0.0-dev ]
paths-ignore:
- '**/*.md'
- '**/*.rst'
Expand All @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["2.7", "3.6", "3.7", "3.10.1", "3.8", "3.9", "3.10"]
python-version: ["3.6", "3.7", "3.10.1", "3.8", "3.9", "3.10"]

steps:
- name: Checkout Code
Expand All @@ -36,32 +36,25 @@ jobs:
run: |
python -m pip install --upgrade pip
- name: Install requirements (Python 3)
if: matrix.python-version != '2.7'
run: |
pip install -r requirements/ci.txt
- name: Install requirements (Python 2)
if: matrix.python-version == '2.7'
run: |
pip install pillow pytest coverage
- name: Install PyPDF2
run: |
pip install .
- name: Test with flake8
run: |
flake8 . --ignore=E203,W503,W504,E,F403,F405 --exclude build,sample-files
if: matrix.python-version != '2.7'
- name: Test with pytest
run: |
python -m coverage run --parallel-mode -m pytest Tests -vv
if: matrix.python-version != '3.10.1' && matrix.python-version != 2.7
- name: Test with pytest (2.7)
run: |
python -m coverage run --parallel-mode -m pytest Tests -vv -m "not no_py27"
if: matrix.python-version == 2.7
python -m coverage run --parallel-mode -m pytest tests -vv
if: matrix.python-version != '3.10.1'
- name: Test with pytest (OO flag)
run: |
python -OO -m coverage run --parallel-mode -m pytest Tests -vv
python -OO -m coverage run --parallel-mode -m pytest tests -vv
if: matrix.python-version == '3.10.1'
- name: Test with mypy
run : |
mypy PyPDF2 --show-error-codes --disallow-untyped-defs --disallow-incomplete-defs
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -10,6 +10,7 @@ repos:
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: "resources/.*"
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-added-large-files
Expand All @@ -35,6 +36,7 @@ repos:
rev: 22.3.0
hooks:
- id: black
args: [--target-version, py36]
# - repo: https://github.com/asottile/pyupgrade
# rev: v2.31.1
# hooks:
Expand All @@ -45,3 +47,8 @@ repos:
hooks:
- id: blacken-docs
additional_dependencies: [black==22.1.0]
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py36-plus]
36 changes: 36 additions & 0 deletions CHANGELOG
@@ -1,3 +1,39 @@
Version 2.0.0
-------------

Breaking Changes(DEP):
- PyPDF2 2.0 requires Python 3.6+. Python 2.7 and 3.5 support were dropped.
- PdfFileReader: The "warndest" parameter was removed
- PdfFileReader and PdfFileMerger no longer have the `overwriteWarnings`
parameter. The new behavior is `overwriteWarnings=False`.
- merger: OutlinesObject was removed without replacement.
- merger.py ➔ _merger.py: You must import PdfFileMerger from PyPDF2 directly.
- utils:
* `ConvertFunctionsToVirtualList` was removed
* `formatWarning` was removed
* `isInt(obj)`: Use `instance(obj, int)` instead
* `u_(s)`: Use `s` directly
* `chr_(c)`: Use `chr(c)` instead
* `barray(b)`: Use `bytearray(b)` instead
* `isBytes(b)`: Use `instance(b, type(bytes()))` instead
* `xrange_fn`: Use `range` instead
* `string_type`: Use `str` instead
* `isString(s)`: Use `instance(s, str)` instead
* `_basestring`: Use `str` instead
* All Exceptions are now in `PyPDF2.errors`:
- PageSizeNotDefinedError
- PdfReadError
- PdfReadWarning
- PyPdfError
- `PyPDF2.pdf` (the `pdf` module) no longer exists. The contents were moved with
the library. You should most likely import directly from `PyPDF2` instead.
The `RectangleObject` is in `PyPDF2.generic`.
- The `Resources`, `Scripts`, and `Tests` will no longer be part of the distribution
files on PyPI. This should have little to no impact on most people. The
`Tests` are renamed to `tests`, the `Resources` are renamed to `resources`.
Both are still in the git repository. The `Scripts` are now in
https://github.com/py-pdf/cpdf. `Sample_Code` was moved to the `docs`.

Version 1.27.12, 2022-05-02
---------------------------

Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in
@@ -1,5 +1,2 @@
include CHANGELOG
include LICENSE
recursive-include Resources *
recursive-include Scripts *
recursive-include Tests *
9 changes: 6 additions & 3 deletions Makefile
Expand Up @@ -14,10 +14,13 @@ upload:
clean:
python setup.py clean --all
pyclean .
rm -rf Tests/__pycache__ PyPDF2/__pycache__ Image9.png htmlcov docs/_build dist dont_commit_merged.pdf dont_commit_writer.pdf PyPDF2.egg-info PyPDF2_pdfLocation.txt .pytest_cache .mypy_cache .benchmarks
rm -rf tests/__pycache__ PyPDF2/__pycache__ Image9.png htmlcov docs/_build dist dont_commit_merged.pdf dont_commit_writer.pdf PyPDF2.egg-info PyPDF2_pdfLocation.txt .pytest_cache .mypy_cache .benchmarks

test:
pytest Tests --cov --cov-report term-missing -vv --cov-report html --durations=3 --timeout=30
pytest tests --cov --cov-report term-missing -vv --cov-report html --durations=3 --timeout=30

testtype:
pytest tests --cov --cov-report term-missing -vv --cov-report html --durations=3 --timeout=30 --typeguard-packages=PyPDF2

mutation-test:
mutmut run
Expand All @@ -27,4 +30,4 @@ mutmut-results:
junit2html mutmut-results.xml mutmut-results.html

benchmark:
pytest Tests/bench.py
pytest tests/bench.py
26 changes: 15 additions & 11 deletions PyPDF2/__init__.py
@@ -1,18 +1,22 @@
from PyPDF2 import pdf
from PyPDF2._reader import PdfFileReader
from PyPDF2._version import __version__
from PyPDF2._writer import PdfFileWriter
from PyPDF2.merger import PdfFileMerger
from PyPDF2.pagerange import PageRange, parse_filename_page_ranges
from PyPDF2.papersizes import PaperSize
from ._merger import PdfMerger
from ._page import Transformation
from ._reader import DocumentInformation, PdfFileReader, PdfReader
from ._version import __version__
from ._writer import PdfFileWriter, PdfWriter
from .pagerange import PageRange, parse_filename_page_ranges
from .papersizes import PaperSize

__all__ = [
"__version__",
"PageRange",
"PaperSize",
"DocumentInformation",
"parse_filename_page_ranges",
"pdf",
"PdfFileMerger",
"PdfFileReader",
"PdfFileWriter",
"PdfFileMerger", # will be removed soon; use PdfMerger instead
"PdfFileReader", # will be removed soon; use PdfReader instead
"PdfFileWriter", # will be removed soon; use PdfWriter instead
"PdfMerger",
"Transformation",
"PdfReader",
"PdfWriter",
]