Skip to content

Commit c2b3bb1

Browse files
DEV: Update code style libraries to latest versions (#3460)
1 parent 20425af commit c2b3bb1

File tree

11 files changed

+28
-24
lines changed

11 files changed

+28
-24
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pre-commit run --all-files
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v5.0.0
4+
rev: v6.0.0
55
hooks:
66
- id: check-ast
77
- id: check-case-conflict
@@ -19,7 +19,7 @@ repos:
1919
args: ['--maxkb=1000']
2020

2121
- repo: https://github.com/charliermarsh/ruff-pre-commit
22-
rev: v0.12.7
22+
rev: v0.13.0
2323
hooks:
2424
- id: ruff-check
2525
args: ['--fix']
@@ -31,7 +31,7 @@ repos:
3131
args: [--py39-plus]
3232

3333
- repo: https://github.com/pre-commit/mirrors-mypy
34-
rev: 'v1.17.0'
34+
rev: v1.17.1
3535
hooks:
3636
- id: mypy
3737
additional_dependencies: [types-Pillow==10.2.0.20240822]

pypdf/_writer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ def _update_field_annotation(
975975
font_res = dr.get(font_name, None)
976976
if not is_null_or_none(font_res):
977977
font_res = cast(DictionaryObject, font_res.get_object())
978-
font_subtype, _, font_encoding, font_map = build_char_map_from_dict(
978+
_font_subtype, _, font_encoding, font_map = build_char_map_from_dict(
979979
200, font_res
980980
)
981981
try: # remove width stored in -1 key
@@ -2740,7 +2740,7 @@ def merge(
27402740
if isinstance(fileobj, PdfDocCommon):
27412741
reader = fileobj
27422742
else:
2743-
stream, encryption_obj = self._create_stream(fileobj)
2743+
stream, _encryption_obj = self._create_stream(fileobj)
27442744
# Create a new PdfReader instance using the stream
27452745
# (either file or BytesIO or StringIO) created above
27462746
reader = PdfReader(stream, strict=False) # type: ignore[arg-type]

pypdf/generic/_data_structures.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,8 +1053,7 @@ def decode_as_image(self) -> Any:
10531053
Returns:
10541054
a PIL image if proper decoding has been found
10551055
Raises:
1056-
Exception: (any)during decoding to to invalid object or
1057-
errors during decoding will be reported
1056+
Exception: Errors during decoding will be reported.
10581057
It is recommended to catch exceptions to prevent
10591058
stops in your program.
10601059
@@ -1067,7 +1066,7 @@ def decode_as_image(self) -> Any:
10671066
except AttributeError:
10681067
msg = f"{self.__repr__()} object does not seem to be an Image" # pragma: no cover
10691068
logger_warning(msg, __name__)
1070-
extension, byte_stream, img = _xobj_to_image(self)
1069+
extension, _, img = _xobj_to_image(self)
10711070
if extension is None:
10721071
return None # pragma: no cover
10731072
return img

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ ignore = [
199199
"TRY301", # Abstract `raise` to an inner function
200200
"UP006", # Non-PEP 585 annotation. As long as we are not on Python 3.11+
201201
"UP007", # Non-PEP 604 annotation. As long as we are not on Python 3.11+
202-
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` - PEP 604. While not on Python 3.10+
203202
]
204203

205204
[tool.ruff.lint.mccabe]

requirements/ci-3.11.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pytest-xdist==3.6.1
6060
# via -r requirements/ci.in
6161
pyyaml==6.0.2
6262
# via -r requirements/ci.in
63-
ruff==0.12.7
63+
ruff==0.13.0
6464
# via -r requirements/ci.in
6565
tomli==2.0.2
6666
# via

tests/test_filters.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_ascii85decode_five_zero_bytes():
194194
def test_ccitparameters():
195195
with pytest.raises(
196196
DeprecationError,
197-
match="CCITParameters is deprecated and was removed in pypdf 6.0.0. Use CCITTParameters instead",
197+
match=r"CCITParameters is deprecated and was removed in pypdf 6\.0\.0\. Use CCITTParameters instead",
198198
):
199199
CCITParameters()
200200

@@ -382,7 +382,7 @@ def test_iss1787():
382382
obj = data.indirect_reference.get_object()
383383
obj["/DecodeParms"][NameObject("/Columns")] = NumberObject(1000)
384384
obj.decoded_self = None
385-
with pytest.raises(expected_exception=PdfReadError, match="^Unsupported PNG filter 244$"):
385+
with pytest.raises(expected_exception=PdfReadError, match=r"^Unsupported PNG filter 244$"):
386386
_ = reader.pages[0].images[0]
387387

388388

@@ -712,7 +712,7 @@ def test_flate_decode__not_rectangular(caplog):
712712

713713
def test_jbig2decode__binary_errors():
714714
with mock.patch("pypdf.filters.JBIG2DEC_BINARY", None), \
715-
pytest.raises(DependencyError, match="jbig2dec binary is not available."):
715+
pytest.raises(DependencyError, match=r"jbig2dec binary is not available\."):
716716
JBIG2Decode.decode(b"dummy")
717717

718718
result = subprocess.CompletedProcess(
@@ -725,7 +725,7 @@ def test_jbig2decode__binary_errors():
725725
)
726726
with mock.patch("pypdf.filters.subprocess.run", return_value=result), \
727727
mock.patch("pypdf.filters.JBIG2DEC_BINARY", "/usr/bin/jbig2dec"), \
728-
pytest.raises(DependencyError, match="jbig2dec>=0.15 is required."):
728+
pytest.raises(DependencyError, match=r"jbig2dec>=0.15 is required\."):
729729
JBIG2Decode.decode(b"dummy")
730730

731731

@@ -785,7 +785,7 @@ def test_jbig2decode__edge_cases(caplog):
785785
caplog.clear()
786786

787787
# Invalid input.
788-
with pytest.raises(PdfStreamError, match="Unable to decode JBIG2 data. Exit code: 1"):
788+
with pytest.raises(PdfStreamError, match=r"Unable to decode JBIG2 data\. Exit code: 1"):
789789
JBIG2Decode.decode(b"aaaaaa")
790790
assert caplog.messages == [
791791
"jbig2dec FATAL ERROR page has no image, cannot be completed",

tests/test_generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def test_name_object(caplog):
200200

201201
with pytest.raises(
202202
DeprecationError,
203-
match="surfix is deprecated and was removed in pypdf 5.0.0. Use prefix instead.",
203+
match=r"surfix is deprecated and was removed in pypdf 5\.0\.0\. Use prefix instead\.",
204204
):
205205
_ = NameObject.surfix
206206

tests/test_reader.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,15 +745,21 @@ def test_decode_permissions():
745745
print_["print"] = True
746746
with pytest.raises(
747747
DeprecationError,
748-
match="decode_permissions is deprecated and was removed in pypdf 5.0.0. Use user_access_permissions instead",
748+
match=(
749+
r"decode_permissions is deprecated and was removed in pypdf 5\.0\.0\. "
750+
r"Use user_access_permissions instead"
751+
),
749752
):
750753
assert reader.decode_permissions(4) == print_
751754

752755
modify = base.copy()
753756
modify["modify"] = True
754757
with pytest.raises(
755758
DeprecationError,
756-
match="decode_permissions is deprecated and was removed in pypdf 5.0.0. Use user_access_permissions instead",
759+
match=(
760+
r"decode_permissions is deprecated and was removed in pypdf 5\.0\.0\. "
761+
r"Use user_access_permissions instead"
762+
),
757763
):
758764
assert reader.decode_permissions(8) == modify
759765

@@ -1820,7 +1826,7 @@ def test_issue2886(caplog):
18201826
url = "https://github.com/user-attachments/files/17187711/crash-e8a85d82de01cab5eb44e7993304d8b9d1544970.pdf"
18211827
name = "issue2886.pdf"
18221828

1823-
with pytest.raises(PdfReadError, match="Unexpected empty line in Xref table."):
1829+
with pytest.raises(PdfReadError, match=r"Unexpected empty line in Xref table\."):
18241830
_ = PdfReader(BytesIO(get_data_from_url(url, name=name)))
18251831

18261832

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def foo() -> None:
236236

237237
with pytest.raises(
238238
DeprecationError,
239-
match="foo is deprecated and was removed in pypdf 4.3.2.",
239+
match=r"foo is deprecated and was removed in pypdf 4\.3\.2\.",
240240
):
241241
foo()
242242

tests/test_writer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,13 +2671,13 @@ def test_deprecate_with_as():
26712671
with PdfWriter() as writer:
26722672
with pytest.raises(
26732673
expected_exception=DeprecationError,
2674-
match="with_as_usage is deprecated and was removed in pypdf 5.0"
2674+
match=r"with_as_usage is deprecated and was removed in pypdf 5\.0"
26752675
):
26762676
_ = writer.with_as_usage
26772677

26782678
with pytest.raises(
26792679
expected_exception=DeprecationError,
2680-
match="with_as_usage is deprecated and was removed in pypdf 5.0"
2680+
match=r"with_as_usage is deprecated and was removed in pypdf 5\.0"
26812681
):
26822682
writer.with_as_usage = False # old code allowed setting this, so...
26832683

0 commit comments

Comments
 (0)