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

DEV: Create flake8 config file #916

Merged
merged 6 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
ignore = 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
4 changes: 2 additions & 2 deletions PyPDF2/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def decompress(data: bytes) -> bytes:
except zlib.error:
d = zlib.decompressobj(zlib.MAX_WBITS | 32)
result_str = b""
for b in [data[i : i + 1] for i in range(len(data))]:
MasterOdin marked this conversation as resolved.
Show resolved Hide resolved
for b in [data[i: i + 1] for i in range(len(data))]:
try:
result_str += d.decompress(b)
except zlib.error:
Expand Down Expand Up @@ -126,7 +126,7 @@ def _decode_png_prediction(data: str, columns: int) -> str:
prev_rowdata = (0,) * rowlength
for row in range(len(data) // rowlength):
rowdata = [
ord_(x) for x in data[(row * rowlength) : ((row + 1) * rowlength)]
ord_(x) for x in data[(row * rowlength): ((row + 1) * rowlength)]
]
filter_byte = rowdata[0]
if filter_byte == 0:
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
4 changes: 2 additions & 2 deletions PyPDF2/xmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ def custom_properties(self) -> Dict[Any, Any]:
break
key = (
key[:idx]
+ chr(int(key[idx + 1 : idx + 5], base=16))
+ key[idx + 5 :]
+ chr(int(key[idx + 1: idx + 5], base=16))
+ key[idx + 5:]
)
if node.nodeType == node.ATTRIBUTE_NODE:
value = node.nodeValue
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