Skip to content

Commit

Permalink
STY: Apply pre-commit (black, isort) + use snake_case variables (#832)
Browse files Browse the repository at this point in the history
This change standardizes the code formatting quite a bit.
Having standardized formatting makes the code easier to read
and reduces the diff.

This includes:

* Applying the black auto-formatter (also in the docs)
* Applying isort for import sorting
* Making sure that files end with a newline

Additionally, in several places the property function call style was replaced by the decorator style
  • Loading branch information
MartinThoma committed Apr 28, 2022
1 parent 7ec5c72 commit 1a190da
Show file tree
Hide file tree
Showing 23 changed files with 1,870 additions and 1,137 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Replace this: What happened? What were you trying to achieve?
Which environment were you using when you encountered the problem?

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

$ python -c "import PyPDF2;print(PyPDF2.__version__)"
Expand Down
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ How would your feature be used? (Remove this if it is not applicable.)

```python
from PyPDF2 import PdfFileReader, PdfFileWriter

... # your new feature in action!
```
```
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@MartinThoma'
alert-comment-cc-users: '@MartinThoma'
2 changes: 1 addition & 1 deletion .github/workflows/github-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ jobs:
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
files: ./coverage.xml
1 change: 1 addition & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ indent=' '
multi_line_output=3
length_sort=0
include_trailing_comma=True
known_third_party = dataclasses,pytest,setuptools
18 changes: 13 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pre-commit run --all-files
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.1.0
hooks:
- id: check-ast
- id: check-byte-order-marker
Expand All @@ -23,10 +23,18 @@ repos:
# rev: v0.942
# hooks:
# - id: mypy
# - repo: https://github.com/psf/black
# rev: 22.3.0
# hooks:
# - id: black
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
# - repo: https://github.com/asottile/pyupgrade
# rev: v2.31.1
# hooks:
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Bug fixes (BUG):

Robustness improvements (ROBUST):

- title sometimes None (#744)
- title sometimes None (#744)

Documentation (DOC):

Expand Down Expand Up @@ -235,7 +235,7 @@ Patch release 1.27.3, 2022-04-10
- BUG: Error in Chinese character encoding (#463)
- BUG: Code duplication in Scripts/2-up.py
- ROBUST: Guard 'obj.writeToStream' with 'if obj is not None'
- ROBUST: Ignore a /Prev entry with the value 0 in the trailer
- ROBUST: Ignore a /Prev entry with the value 0 in the trailer
- MAINT: Remove Sample_Code (#726)
- TST: Close file handle in test_writer (#722)
- TST: Fix test_get_images (#730)
Expand Down
2 changes: 1 addition & 1 deletion PyPDF2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from PyPDF2 import pdf
from PyPDF2._version import __version__
from PyPDF2.merger import PdfFileMerger
from PyPDF2.pagerange import PageRange, parse_filename_page_ranges
from PyPDF2.papersizes import PaperSize
from PyPDF2.pdf import PdfFileReader, PdfFileWriter
from PyPDF2 import pdf

__all__ = [
"__version__",
Expand Down
Loading

0 comments on commit 1a190da

Please sign in to comment.