Skip to content

Commit

Permalink
DEV: Create flake8 config file (#916)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Peveler <[email protected]>
  • Loading branch information
MasterOdin authored May 28, 2022
1 parent 07bb859 commit bbfd46c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
# The flake8 config should work well with black,
# see https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
ignore = E203,E501,E741,W503,W604
exclude = build,sample-files
2 changes: 1 addition & 1 deletion .github/workflows/github-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
pip install .
- name: Test with flake8
run: |
flake8 . --ignore=E203,W503,W504,E,F403,F405 --exclude build,sample-files
flake8 .
- name: Test with pytest
run: |
python -m coverage run --parallel-mode -m pytest tests -vv
Expand Down
2 changes: 1 addition & 1 deletion PyPDF2/_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ def read_next_end_line(self, stream: StreamType, limit_offset: int = 0) -> bytes
if stream.tell() < 2:
raise PdfReadError("EOL marker not found")
stream.seek(-2, 1)
if x == b_("\n") or x == b_("\r"): ## \n = LF; \r = CR
if x == b_("\n") or x == b_("\r"): # \n = LF; \r = CR
crlf = False
while x == b_("\n") or x == b_("\r"):
x = stream.read(1)
Expand Down
6 changes: 3 additions & 3 deletions PyPDF2/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def write_to_stream(
if encryption_key:
from ._security import RC4_encrypt

bytearr = RC4_encrypt(encryption_key, bytearr) # type: ignore
bytearr = RC4_encrypt(encryption_key, bytearr) # type: ignore
stream.write(b_("<"))
stream.write(hexencode(bytearr))
stream.write(b_(">"))
Expand Down Expand Up @@ -2144,15 +2144,15 @@ def decode_pdfdocencoding(byte_array: bytes) -> str:
"\u0004",
"\u0005",
"\u0006",
"\u0007", # 0 - 7
"\u0007", # 0 - 7
"\u0008",
"\u0009",
"\u000a",
"\u000b",
"\u000c",
"\u000d",
"\u000e",
"\u000f", # 8 - 15
"\u000f", # 8 - 15
"\u0010",
"\u0011",
"\u0012",
Expand Down
8 changes: 4 additions & 4 deletions tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ def test_boolean_object_write():

def test_boolean_eq():
boolobj = BooleanObject(True)
assert (boolobj == True) is True
assert (boolobj == False) is False
assert (boolobj == True) is True # noqa: E712
assert (boolobj == False) is False # noqa: E712
assert (boolobj == "True") is False

boolobj = BooleanObject(False)
assert (boolobj == True) is False
assert (boolobj == False) is True
assert (boolobj == True) is False # noqa: E712
assert (boolobj == False) is True # noqa: E712
assert (boolobj == "True") is False


Expand Down
4 changes: 2 additions & 2 deletions tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def test_decrypt():
os.path.join(RESOURCE_ROOT, "libreoffice-writer-password.pdf"), "rb"
) as inputfile:
reader = PdfReader(inputfile)
assert reader.is_encrypted == True
assert reader.is_encrypted is True
reader.decrypt("openpassword")
assert len(reader.pages) == 1
assert reader.is_encrypted == True
assert reader.is_encrypted is True
metadict = reader.metadata
assert dict(metadict) == {
"/CreationDate": "D:20220403203552+02'00'",
Expand Down

0 comments on commit bbfd46c

Please sign in to comment.