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

MAINT: Upgrade to ruff==0.8.4 #3022

Merged
merged 4 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 8 additions & 8 deletions pypdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@
)

__all__ = [
"__version__",
"_debug_versions",
"DocumentInformation",
"ImageType",
"mult",
"ObjectDeletionFlag",
"PageObject",
"PageRange",
"PaperSize",
"DocumentInformation",
"ObjectDeletionFlag",
"parse_filename_page_ranges",
"PasswordType",
"PdfMerger",
"PdfReader",
"PdfWriter",
"Transformation",
"PageObject",
"PasswordType",
"__version__",
"_debug_versions",
"mult",
"parse_filename_page_ranges",
]
10 changes: 5 additions & 5 deletions pypdf/_codecs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ def rev_encoding(enc: List[str]) -> Dict[str, int]:
}

__all__ = [
"adobe_glyphs",
"_std_encoding",
"_symbol_encoding",
"_zapfding_encoding",
"_mac_encoding",
"_pdfdoc_encoding",
"_pdfdoc_encoding_rev",
"_std_encoding",
"_symbol_encoding",
"_win_encoding",
"_mac_encoding",
"_zapfding_encoding",
"adobe_glyphs",
"charset_encoding",
]
14 changes: 7 additions & 7 deletions pypdf/_crypt_providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@
)

__all__ = [
"crypt_provider",
"CryptAES",
"CryptBase",
"CryptIdentity",
"CryptRC4",
"CryptAES",
"rc4_encrypt",
"rc4_decrypt",
"aes_ecb_encrypt",
"aes_ecb_decrypt",
"aes_cbc_encrypt",
"aes_cbc_decrypt",
"aes_cbc_encrypt",
"aes_ecb_decrypt",
"aes_ecb_encrypt",
"crypt_provider",
"rc4_decrypt",
"rc4_encrypt",
]
13 changes: 5 additions & 8 deletions pypdf/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,10 +749,7 @@ def _translate_value_inlineimage(self, k: str, v: PdfObject) -> PdfObject:
return v

def _get_inline_images(self) -> Dict[str, ImageFile]:
"""
get inline_images
entries will be identified as ~1~
"""
"""Load inline images. Entries will be identified as `~1~`."""
content = self.get_contents()
if is_null_or_none(content):
return {}
Expand Down Expand Up @@ -1451,7 +1448,7 @@ def merge_transformed_page(
expand: bool = False,
) -> None:
"""
merge_transformed_page is similar to merge_page, but a transformation
Similar to :meth:`~pypdf._page.PageObject.merge_page`, but a transformation
matrix is applied to the merged stream.

Args:
Expand Down Expand Up @@ -1479,7 +1476,7 @@ def merge_scaled_page(
self, page2: "PageObject", scale: float, over: bool = True, expand: bool = False
) -> None:
"""
merge_scaled_page is similar to merge_page, but the stream to be merged
Similar to :meth:`~pypdf._page.PageObject.merge_page`, but the stream to be merged
is scaled by applying a transformation matrix.

Args:
Expand All @@ -1501,7 +1498,7 @@ def merge_rotated_page(
expand: bool = False,
) -> None:
"""
merge_rotated_page is similar to merge_page, but the stream to be merged
Similar to :meth:`~pypdf._page.PageObject.merge_page`, but the stream to be merged
is rotated by applying a transformation matrix.

Args:
Expand All @@ -1524,7 +1521,7 @@ def merge_translated_page(
expand: bool = False,
) -> None:
"""
mergeTranslatedPage is similar to merge_page, but the stream to be
Similar to :meth:`~pypdf._page.PageObject.merge_page`, but the stream to be
merged is translated by applying a transformation matrix.

Args:
Expand Down
2 changes: 1 addition & 1 deletion pypdf/_text_extraction/_layout_mode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from ._font import Font

__all__ = [
"Font",
"fixed_char_width",
"fixed_width_page",
"text_show_operations",
"y_coordinate_groups",
"Font",
]
2 changes: 1 addition & 1 deletion pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def insert_blank_page(
and previous page does not exist.

"""
if width is None or height is None and index < self.get_num_pages():
if width is None or (height is None and index < self.get_num_pages()):
oldpage = self.pages[index]
width = oldpage.mediabox.width
height = oldpage.mediabox.height
Expand Down
11 changes: 4 additions & 7 deletions pypdf/annotations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@

__all__ = [
"NO_FLAGS",
# Export abstract base classes so that they are shown in the docs
"AnnotationDictionary",
"MarkupAnnotation",
# Markup annotations
"Ellipse",
"FreeText",
"Highlight",
"Line",
"Polygon",
"Link",
"MarkupAnnotation",
"PolyLine",
"Polygon",
"Popup",
"Rectangle",
"Text",
# Non-markup annotations
"Link",
"Popup",
]
46 changes: 20 additions & 26 deletions pypdf/generic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,45 +198,39 @@ def link(


__all__ = [
# Base types
"PAGE_FIT",
"AnnotationBuilder",
"ArrayObject",
"BooleanObject",
"ByteStringObject",
"ContentStream",
"DecodedStreamObject",
"Destination",
"DictionaryObject",
"EncodedStreamObject",
"Field",
"Fit",
"FloatObject",
"NumberObject",
"NameObject",
"IndirectObject",
"NameObject",
"NullObject",
"NumberObject",
"OutlineFontFlag",
"OutlineItem",
"PdfObject",
"RectangleObject",
"StreamObject",
"TextStringObject",
"ByteStringObject",
# Annotations
"AnnotationBuilder",
# Fit
"Fit",
"PAGE_FIT",
# Data structures
"ArrayObject",
"DictionaryObject",
"TreeObject",
"StreamObject",
"DecodedStreamObject",
"EncodedStreamObject",
"ContentStream",
"RectangleObject",
"Field",
"Destination",
"ViewerPreferences",
# --- More specific stuff
# Outline
"OutlineItem",
"OutlineFontFlag",
# Data structures core functions
"read_object",
# Utility functions
"create_string_object",
"encode_pdfdocencoding",
"decode_pdfdocencoding",
"encode_pdfdocencoding",
"hex_to_rgb",
"is_null_or_none",
"read_hex_string_from_stream",
# Data structures core functions
"read_object",
"read_string_from_stream",
]
10 changes: 5 additions & 5 deletions pypdf/generic/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ def hash_bin(self) -> int:
"""
return hash((self.__class__, self.value))

def __eq__(self, __o: object) -> bool:
if isinstance(__o, BooleanObject):
return self.value == __o.value
elif isinstance(__o, bool):
return self.value == __o
def __eq__(self, o: object, /) -> bool:
if isinstance(o, BooleanObject):
return self.value == o.value
elif isinstance(o, bool):
return self.value == o
else:
return False

Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ ignore = [
"N806", # Variable `NO` in function should be lowercase
"N814", # Camelcase `PageAttributes` imported as constant `PG`
"N817", # CamelCase `PagesAttributes` imported as acronym `PA`
"ANN101", # annotating 'self' seems weird (at least before 3.11)
"ANN102", # Missing type annotation for `cls` in classmethod
"ANN204", # Missing return type annotation for special method `__init__`
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"BLE", # we want to capture Exception sometimes
Expand Down
2 changes: 1 addition & 1 deletion requirements/ci-3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pytest-xdist==3.6.1
# via -r requirements/ci.in
pyyaml==6.0.2
# via -r requirements/ci.in
ruff==0.7.0
ruff==0.8.4
# via -r requirements/ci.in
tomli==2.0.2
# via
Expand Down
4 changes: 2 additions & 2 deletions tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ def test_cloning(caplog):
@pytest.mark.enable_socket
def test_append_with_indirectobject_not_pointing(caplog):
"""
reported in #1631
Reported in #1631
the object 43 0 is not invalid
"""
url = "https://github.com/py-pdf/pypdf/files/10729142/document.pdf"
Expand All @@ -912,7 +912,7 @@ def test_append_with_indirectobject_not_pointing(caplog):
@pytest.mark.enable_socket
def test_iss1615_1673():
"""
test cases where /N is not indicating chains of objects
Test cases where /N is not indicating chains of objects
test also where /N,... are not part of chains
"""
# #1615
Expand Down
Loading