From 8dbfeba695314241bfca7fe48fd2bc880cf6c538 Mon Sep 17 00:00:00 2001 From: Stefan <96178532+stefan6419846@users.noreply.github.com> Date: Wed, 27 Mar 2024 19:28:12 +0100 Subject: [PATCH] MAINT: Fix typos found by codespell (#2549) --- CHANGELOG.md | 18 +++++++-------- docs/meta/changelog-v1.md | 6 ++--- docs/meta/taking-ownership.md | 2 +- docs/modules/PdfDocCommon.md | 2 +- docs/user/add-watermark.md | 2 +- docs/user/cropping-and-transforming.md | 4 ++-- docs/user/forms.md | 4 ++-- docs/user/pdfa-compliance.md | 2 +- docs/user/suppress-warnings.md | 2 +- pypdf/_doc_common.py | 15 +++++++------ pypdf/_merger.py | 4 ++-- pypdf/_page.py | 4 ++-- .../_layout_mode/_text_state_manager.py | 2 +- pypdf/_writer.py | 22 +++++++++---------- pypdf/_xobj_image_helpers.py | 2 +- pypdf/filters.py | 10 ++++----- pypdf/generic/__init__.py | 2 +- pypdf/generic/_data_structures.py | 12 +++++----- tests/test_encryption.py | 2 +- tests/test_filters.py | 12 +++++----- tests/test_page.py | 4 ++-- tests/test_reader.py | 6 ++--- tests/test_utils.py | 2 +- tests/test_workflows.py | 4 ++-- tests/test_writer.py | 8 +++---- 25 files changed, 77 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3adaf92d5..53c5828b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -243,7 +243,7 @@ nobody will be affected though. Hence only the patch update. - Avoid endless recursion of reading damaged PDF file (#2093) ### Performance Improvements (PI) -- Re-use content stream (#2101) +- Reuse content stream (#2101) ### Maintenance (MAINT) - Make ParseError inherit from PyPdfError (#2097) @@ -411,7 +411,7 @@ nobody will be affected though. Hence only the patch update. ### New Features (ENH) - Simplify metadata input (Document Information Dictionary) (#1851) -- Extend cmap compatibilty to GBK_EUC_H/V (#1812) +- Extend cmap compatibility to GBK_EUC_H/V (#1812) ### Bug Fixes (BUG) - Prevent infinite loop when no character follows after a comment (#1828) @@ -432,7 +432,7 @@ nobody will be affected though. Hence only the patch update. - Refactor internal Encryption class (#1821) - Add R parameter to generate_values (#1820) - Make encryption_key parameter of write_to_stream optional (#1819) -- Prepare for adding AES enryption support (#1818) +- Prepare for adding AES encryption support (#1818) [Full Changelog](https://github.com/py-pdf/pypdf/compare/3.8.1...3.9.0) @@ -665,7 +665,7 @@ NOTICE: pypdf changed the way it represents numbers parsed from PDF files. ## Version 3.2.0, 2022-12-31 ### Performance Improvement (PI) -- Help the specializing adpative interpreter (#1522) +- Help the specializing adaptive interpreter (#1522) ### New Features (ENH) - Add support for page labels (#1519) @@ -999,12 +999,12 @@ BUG: Add PyPDF2.generic to PyPI distribution ### Documentation (DOC) - Update changelog url in package metadata (#1180) -- Mantion camelot for table extraction (#1179) +- Mention camelot for table extraction (#1179) - Mention pyHanko for signing PDF documents (#1178) - Weow have CMAP support since a while (#1177) ### Maintenance (MAINT) -- Consistant usage of warnings / log messages (#1164) +- Consistent usage of warnings / log messages (#1164) - Consistent terminology for outline items (#1156) @@ -1082,7 +1082,7 @@ BUG: Add PyPDF2.generic to PyPI distribution ### Code Style (STY) - Fixing typos (#1137) -- Re-use code via get_outlines_property in tests (#1130) +- Reuse code via get_outlines_property in tests (#1130) [Full Changelog](https://github.com/py-pdf/PyPDF2/compare/2.6.0...2.7.0) @@ -1246,7 +1246,7 @@ BUG: Add PyPDF2.generic to PyPI distribution ## Version 2.3.1, 2022-06-19 -BUG: Forgot to add the interal `_codecs` subpackage. +BUG: Forgot to add the internal `_codecs` subpackage. [Full Changelog](https://github.com/py-pdf/PyPDF2/compare/2.3.0...2.3.1) @@ -1285,7 +1285,7 @@ The highlight of this release is improved support for file encryption - Fix corrupted (wrongly) linear PDF (#1008) ### Maintenance (MAINT) -- Move PDF_Samples folder into ressources +- Move PDF_Samples folder into resources - Fix typos (#1007) ### Testing (TST) diff --git a/docs/meta/changelog-v1.md b/docs/meta/changelog-v1.md index d4ed5c991..3d9da0412 100644 --- a/docs/meta/changelog-v1.md +++ b/docs/meta/changelog-v1.md @@ -295,13 +295,13 @@ large PDF files (#808) 🎉 ### Bug Fixes (BUG) - Clip by trimBox when merging pages, which would otherwise be ignored (#240) - Add overwriteWarnings parameter PdfFileMerger (#243) -- IndexError for getPage() of decryped file (#359) +- IndexError for getPage() of decrypted file (#359) - Handle cases where decodeParms is an ArrayObject (#405) - Updated PDF fields don't show up when page is written (#412) - Set Linked Form Value (#414) - Fix zlib -5 error for corrupt files (#603) - Fix reading more than last1K for EOF (#642) -- Acciental import +- Accidental import ### Robustness (ROB) - Allow extra whitespace before "obj" in readObjectHeader (#567) @@ -788,7 +788,7 @@ UPCOMING: ## Version 1.18, 2013-08-19 - - Fixed a bug where older verions of objects were incorrectly added to the + - Fixed a bug where older versions of objects were incorrectly added to the cache, resulting in outdated or missing pages, images, and other objects (from speedplane) diff --git a/docs/meta/taking-ownership.md b/docs/meta/taking-ownership.md index 560cb8180..1d3a58caa 100644 --- a/docs/meta/taking-ownership.md +++ b/docs/meta/taking-ownership.md @@ -6,7 +6,7 @@ that if I become unavailable, e.g. due to severe health issues. This currently is just an abstract scenario. I'm fine and I will likely do this for several more years, but I have seen how projects stand still for many years -because of the maintainer becomming inactive. +because of the maintainer becoming inactive. I've also followed the [GitHub Deceased User Policy](https://docs.github.com/en/site-policy/other-site-policies/github-deceased-user-policy) and added a [pre-designated successor](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-access-to-your-personal-repositories/maintaining-ownership-continuity-of-your-personal-accounts-repositories). diff --git a/docs/modules/PdfDocCommon.md b/docs/modules/PdfDocCommon.md index 0b83f5017..9a26d1e8b 100644 --- a/docs/modules/PdfDocCommon.md +++ b/docs/modules/PdfDocCommon.md @@ -2,4 +2,4 @@ **PdfDocCommon** is an abstract class which is inherited by **PdfReader** and **PdfWriter** -Where indentified in the API, you can use any of the derivated class. +Where identified in the API, you can use any of the derived class. diff --git a/docs/user/add-watermark.md b/docs/user/add-watermark.md index 2491fad7f..06abeede4 100644 --- a/docs/user/add-watermark.md +++ b/docs/user/add-watermark.md @@ -69,7 +69,7 @@ Example of watermark: ## Stamping images directly The above code only works for stamps that are already in PDF format. -However, you can easilly convert an image to PDF image using +However, you can easily convert an image to PDF image using [Pillow](https://pypi.org/project/Pillow/). diff --git a/docs/user/cropping-and-transforming.md b/docs/user/cropping-and-transforming.md index 7a9cde79d..9708e327f 100644 --- a/docs/user/cropping-and-transforming.md +++ b/docs/user/cropping-and-transforming.md @@ -26,7 +26,7 @@ writer.add_page(page3) # add some Javascript to launch the print window on opening this PDF. # the password dialog may prevent the print dialog from being shown, -# comment the the encription lines, if that's the case, to try this out: +# comment the the encryption lines, if that's the case, to try this out: writer.add_js("this.print({bUI:true,bSilent:false,bShrinkToFit:true});") # write to document-output.pdf @@ -212,7 +212,7 @@ pypdf._page.MERGE_CROP_BOX = "trimbox" # Transforming several copies of the same page -We have designed the following business card (A8 format) to advertize our new startup. +We have designed the following business card (A8 format) to advertise our new startup. ![](nup-source.png) diff --git a/docs/user/forms.md b/docs/user/forms.md index 7fb932813..d8a0fe6e6 100644 --- a/docs/user/forms.md +++ b/docs/user/forms.md @@ -64,10 +64,10 @@ To flesh out this overview: - `/V`: Field Value - `/DV` : Default Field Value (used when resetting a form for example) * In order to streamline readability, _Field_ Objects and _Widget_ Objects can be fused housing all properties. -* Fields can be organised hierarchically, id est one field can be placed under another. In such instances, the `/Parent` will have an IndirectObject providing Bottom-Up links and `/Childs` is an array carrying IndirectObjects for Top-Down navigation; _Widget_ Objects are still required for visual rendering. To call upon them, use the *fully qualified field name* (where all the individual names of the parent objects are seperated by `.`) +* Fields can be organised hierarchically, id est one field can be placed under another. In such instances, the `/Parent` will have an IndirectObject providing Bottom-Up links and `/Kids` is an array carrying IndirectObjects for Top-Down navigation; _Widget_ Objects are still required for visual rendering. To call upon them, use the *fully qualified field name* (where all the individual names of the parent objects are separated by `.`) For instance take two (visual) fields both called _city_, but attached below _sender_ and _receiver_; the corresponding full names will be _sender.city_ and _receiver.city_. -* When a field is repeated on multiple pages, the Field Object will have many _Widget_ Objects in `/Childs`. These objects are pure _widgets_, containing no _field_ specific data. +* When a field is repeated on multiple pages, the Field Object will have many _Widget_ Objects in `/Kids`. These objects are pure _widgets_, containing no _field_ specific data. * If Fields stores only hidden values, no _Widgets_ are required. In _pypdf_ fields are extracted from the `/Fields` array: diff --git a/docs/user/pdfa-compliance.md b/docs/user/pdfa-compliance.md index f7ae8d6b3..26b93886e 100644 --- a/docs/user/pdfa-compliance.md +++ b/docs/user/pdfa-compliance.md @@ -22,7 +22,7 @@ against future technological changes and obsolescence. improvements over PDF/A-1, while maintaining compatibility with PDF/A-1b (Level B) documents. * **Level B** (Basic): Like PDF/A-1b, but support for PDF 1.7 features such - as transparancy layers. + as transparency layers. * **Level U** (Unicode): Ensures Unicode mapping without the full accessibility requirements of PDF/A-1a (Level A). * **Level A** (Accessible): Similar to PDF/A-1a diff --git a/docs/user/suppress-warnings.md b/docs/user/suppress-warnings.md index 32ab1e0f1..f6479188d 100644 --- a/docs/user/suppress-warnings.md +++ b/docs/user/suppress-warnings.md @@ -20,7 +20,7 @@ pypdf makes use of 3 mechanisms to show that something went wrong: ## Exceptions -Exeptions need to be catched if you want to handle them. For example, you could +Exceptions need to be caught if you want to handle them. For example, you could want to read the text from a PDF as a part of a search function. Most PDF files don't follow the specifications. In this case pypdf needs to diff --git a/pypdf/_doc_common.py b/pypdf/_doc_common.py index edce2ef69..5f063e032 100644 --- a/pypdf/_doc_common.py +++ b/pypdf/_doc_common.py @@ -380,7 +380,7 @@ def named_destinations(self) -> Dict[str, Any]: return self._get_named_destinations() def get_named_dest_root(self) -> ArrayObject: - nd = ArrayObject() + named_dest = ArrayObject() if CA.NAMES in self.root_object and isinstance( self.root_object[CA.NAMES], DictionaryObject ): @@ -392,15 +392,15 @@ def get_named_dest_root(self) -> ArrayObject: dests_ref = dests.indirect_reference if CA.NAMES in dests: # TABLE 3.33 Entries in a name tree node dictionary - nd = cast(ArrayObject, dests[CA.NAMES]) + named_dest = cast(ArrayObject, dests[CA.NAMES]) else: - nd = ArrayObject() - dests[NameObject(CA.NAMES)] = nd + named_dest = ArrayObject() + dests[NameObject(CA.NAMES)] = named_dest elif hasattr(self, "_add_object"): dests = DictionaryObject() dests_ref = self._add_object(dests) names[NameObject(CA.DESTS)] = dests_ref - dests[NameObject(CA.NAMES)] = nd + dests[NameObject(CA.NAMES)] = named_dest elif hasattr(self, "_add_object"): names = DictionaryObject() @@ -409,9 +409,9 @@ def get_named_dest_root(self) -> ArrayObject: dests = DictionaryObject() dests_ref = self._add_object(dests) names[NameObject(CA.DESTS)] = dests_ref - dests[NameObject(CA.NAMES)] = nd + dests[NameObject(CA.NAMES)] = named_dest - return nd + return named_dest ## common def _get_named_destinations( @@ -1208,6 +1208,7 @@ def decode_permissions( "copy": UserAccessPermissions.EXTRACT, "annotations": UserAccessPermissions.ADD_OR_MODIFY, "forms": UserAccessPermissions.FILL_FORM_FIELDS, + # Do not fix typo, as part of official, but deprecated API. "accessability": UserAccessPermissions.EXTRACT_TEXT_AND_GRAPHICS, "assemble": UserAccessPermissions.ASSEMBLE_DOC, "print_high_quality": UserAccessPermissions.PRINT_TO_REPRESENTATION, diff --git a/pypdf/_merger.py b/pypdf/_merger.py index 8758dbec0..7176a1adf 100644 --- a/pypdf/_merger.py +++ b/pypdf/_merger.py @@ -306,8 +306,8 @@ def write(self, fileobj: Union[Path, StrByteType]) -> None: def close(self) -> None: """Shut all file descriptors (input and output) and clear all memory usage.""" self.pages = [] - for fo, _reader in self.inputs: - fo.close() + for file_descriptor, _reader in self.inputs: + file_descriptor.close() self.inputs = [] self.output = None diff --git a/pypdf/_page.py b/pypdf/_page.py index b0bb0dc3f..1c77ce3ba 100644 --- a/pypdf/_page.py +++ b/pypdf/_page.py @@ -924,7 +924,7 @@ def replace_contents( else: content.indirect_reference = self[ PG.CONTENTS - ].indirect_reference # TODO: in a future may required generation managment + ].indirect_reference # TODO: in a future may required generation management try: self.indirect_reference.pdf._objects[ content.indirect_reference.idnum - 1 # type: ignore @@ -1582,7 +1582,7 @@ def _extract_text( # /Resources can be inherited sometimes so we look to parents objr = objr["/Parent"].get_object() # if no parents we will have no /Resources will be available - # => an exception wil be raised + # => an exception will be raised resources_dict = cast(DictionaryObject, objr[PG.RESOURCES]) except Exception: # no resources means no text is possible (no font) we consider the diff --git a/pypdf/_text_extraction/_layout_mode/_text_state_manager.py b/pypdf/_text_extraction/_layout_mode/_text_state_manager.py index 0a7f7780f..3c5d47367 100644 --- a/pypdf/_text_extraction/_layout_mode/_text_state_manager.py +++ b/pypdf/_text_extraction/_layout_mode/_text_state_manager.py @@ -52,7 +52,7 @@ def set_state_param(self, op: bytes, value: Union[float, List[Any]]) -> None: Args: op: operator read from PDF stream as bytes. No action is taken for unsupported operators (see supported operators above). - value (float | List[Any]): new paramater value. If a list, + value (float | List[Any]): new parameter value. If a list, value[0] is used. """ if op not in [b"Tc", b"Tz", b"Tw", b"TL", b"Ts"]: diff --git a/pypdf/_writer.py b/pypdf/_writer.py index 31505bed0..4dbcb5274 100644 --- a/pypdf/_writer.py +++ b/pypdf/_writer.py @@ -413,7 +413,7 @@ def set_need_appearances_writer(self, state: bool = True) -> None: The "NeedAppearances" flag indicates whether the appearance dictionary for form fields should be automatically generated by the PDF viewer or - if the embedded appearence should be used. + if the embedded appearance should be used. Args: state: The actual value of the NeedAppearances flag. @@ -602,7 +602,7 @@ def add_js(self, javascript: str) -> None: >>> output.add_js("this.print({bUI:true,bSilent:false,bShrinkToFit:true});") # Example: This will launch the print window when the PDF is opened. """ - # Names / JavaScript prefered to be able to add multiple scripts + # Names / JavaScript preferred to be able to add multiple scripts if "/Names" not in self._root_object: self._root_object[NameObject(CA.NAMES)] = DictionaryObject() names = cast(DictionaryObject, self._root_object[CA.NAMES]) @@ -724,7 +724,7 @@ def append_pages_from_reader( Copy pages from reader to writer. Includes an optional callback parameter which is invoked after pages are appended to the writer. - ``append`` should be prefered. + ``append`` should be preferred. Args: reader: a PdfReader object from which to copy page @@ -910,7 +910,7 @@ def update_page_form_field_values( if PG.ANNOTS not in page: logger_warning("No fields to update on this page", __name__) return - # /Helvetica is just in case of but this is normally insufficient as we miss the font ressource + # /Helvetica is just in case of but this is normally insufficient as we miss the font resource default_da = af.get( InteractiveFormDictEntries.DA, TextStringObject("/Helvetica 0 Tf 0 g") ) @@ -1620,16 +1620,16 @@ def add_outline(self) -> None: def add_named_destination_array( self, title: TextStringObject, destination: Union[IndirectObject, ArrayObject] ) -> None: - nd = self.get_named_dest_root() + named_dest = self.get_named_dest_root() i = 0 - while i < len(nd): - if title < nd[i]: - nd.insert(i, destination) - nd.insert(i, TextStringObject(title)) + while i < len(named_dest): + if title < named_dest[i]: + named_dest.insert(i, destination) + named_dest.insert(i, TextStringObject(title)) return else: i += 2 - nd.extend([TextStringObject(title), destination]) + named_dest.extend([TextStringObject(title), destination]) return def add_named_destination_object( @@ -2771,7 +2771,7 @@ def reset_translation( Late cloning will create new independent objects. Args: - reader: PdfReader or IndirectObject refering a PdfReader object. + reader: PdfReader or IndirectObject referencing a PdfReader object. if set to None or omitted, all tables will be reset. """ if reader is None: diff --git a/pypdf/_xobj_image_helpers.py b/pypdf/_xobj_image_helpers.py index d18db1b28..cebab1041 100644 --- a/pypdf/_xobj_image_helpers.py +++ b/pypdf/_xobj_image_helpers.py @@ -64,7 +64,7 @@ def _get_imagemode( pass elif not isinstance(color_space, list): raise PdfReadError( - "can not interprete colorspace", color_space + "Cannot interpret colorspace", color_space ) # pragma: no cover elif color_space[0].startswith("/Cal"): # /CalRGB and /CalGray color_space = "/Device" + color_space[0][4:] diff --git a/pypdf/filters.py b/pypdf/filters.py index 7c7c85965..05eee23ff 100644 --- a/pypdf/filters.py +++ b/pypdf/filters.py @@ -597,7 +597,7 @@ def decode( deprecation_no_replacement( "decode_parms being an ArrayObject", removed_in="3.15.5" ) - parms = CCITTFaxDecode._get_parameters(decode_parms, height) + params = CCITTFaxDecode._get_parameters(decode_parms, height) img_size = len(data) tiff_header_struct = "<2shlh" + "hhll" * 8 + "h" @@ -610,11 +610,11 @@ def decode( 256, 4, 1, - parms.columns, # ImageWidth, LONG, 1, width + params.columns, # ImageWidth, LONG, 1, width 257, 4, 1, - parms.rows, # ImageLength, LONG, 1, length + params.rows, # ImageLength, LONG, 1, length 258, 3, 1, @@ -622,7 +622,7 @@ def decode( 259, 3, 1, - parms.group, # Compression, SHORT, 1, 4 = CCITT Group 4 fax encoding + params.group, # Compression, SHORT, 1, 4 = CCITT Group 4 fax encoding 262, 3, 1, @@ -636,7 +636,7 @@ def decode( 278, 4, 1, - parms.rows, # RowsPerStrip, LONG, 1, length + params.rows, # RowsPerStrip, LONG, 1, length 279, 4, 1, diff --git a/pypdf/generic/__init__.py b/pypdf/generic/__init__.py index 8425ad1f0..878a17e49 100644 --- a/pypdf/generic/__init__.py +++ b/pypdf/generic/__init__.py @@ -318,7 +318,7 @@ def highlight( specifying the highlighted area quad_points: An ArrayObject of 8 FloatObjects. Must match a word or a group of words, otherwise no highlight will be shown. - highlight_color: The color used for the hightlight + highlight_color: The color used for the highlight. Returns: A dictionary object representing the annotation. diff --git a/pypdf/generic/_data_structures.py b/pypdf/generic/_data_structures.py index d39e71102..bb62c69cb 100644 --- a/pypdf/generic/_data_structures.py +++ b/pypdf/generic/_data_structures.py @@ -899,27 +899,27 @@ def flate_encode(self, level: int = -1) -> "EncodedStreamObject": if isinstance(f, ArrayObject): f = ArrayObject([NameObject(FT.FLATE_DECODE), *f]) try: - parms = ArrayObject( + params = ArrayObject( [NullObject(), *self.get(SA.DECODE_PARMS, ArrayObject())] ) except TypeError: # case of error where the * operator is not working (not an array - parms = ArrayObject( + params = ArrayObject( [NullObject(), self.get(SA.DECODE_PARMS, ArrayObject())] ) else: f = ArrayObject([NameObject(FT.FLATE_DECODE), f]) - parms = ArrayObject( + params = ArrayObject( [NullObject(), self.get(SA.DECODE_PARMS, NullObject())] ) else: f = NameObject(FT.FLATE_DECODE) - parms = None + params = None retval = EncodedStreamObject() retval.update(self) retval[NameObject(SA.FILTER)] = f - if parms is not None: - retval[NameObject(SA.DECODE_PARMS)] = parms + if params is not None: + retval[NameObject(SA.DECODE_PARMS)] = params retval._data = FlateDecode.encode(b_(self._data), level) return retval diff --git a/tests/test_encryption.py b/tests/test_encryption.py index f15e072fa..39ee17453 100644 --- a/tests/test_encryption.py +++ b/tests/test_encryption.py @@ -204,7 +204,7 @@ def test_attempt_decrypt_unencrypted_pdf(): """Attempting to decrypt an unencrypted PDF raises a PdfReadError.""" path = RESOURCE_ROOT / "crazyones.pdf" with pytest.raises(PdfReadError) as exc: - PdfReader(path, password="nonexistant") + PdfReader(path, password="nonexistent") assert exc.value.args[0] == "Not encrypted file" diff --git a/tests/test_filters.py b/tests/test_filters.py index 1691c30b3..6edd4c513 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -190,9 +190,9 @@ def test_ascii85decode_five_zero_bytes(): def test_ccitparameters(): - parms = CCITParameters() - assert parms.K == 0 # zero is the default according to page 78 - assert parms.group == 3 + params = CCITParameters() + assert params.K == 0 # zero is the default according to page 78 + assert params.group == 3 @pytest.mark.parametrize( @@ -203,8 +203,8 @@ def test_ccitparameters(): ], ) def test_ccitt_get_parameters(parameters, expected_k): - parmeters = CCITTFaxDecode._get_parameters(parameters=parameters, rows=0) - assert parmeters.K == expected_k # noqa: SIM300 + parameters = CCITTFaxDecode._get_parameters(parameters=parameters, rows=0) + assert parameters.K == expected_k # noqa: SIM300 def test_ccitt_fax_decode(): @@ -313,7 +313,7 @@ def test_pa_image_extraction(): assert len(images) == 1 assert images[0].name == "Im1.png" - # Ensure visual appearence + # Ensure visual appearance data = get_data_from_url(name="issue-1801.png") assert data == images[0].data diff --git a/tests/test_page.py b/tests/test_page.py index a2930727f..0f257ac39 100644 --- a/tests/test_page.py +++ b/tests/test_page.py @@ -135,7 +135,7 @@ def test_mediabox_expansion_after_rotation( angle: float, expected_width: int, expected_height: int ): """ - Mediabox dimensions after rotation at a non-right angle with expension are correct. + Mediabox dimensions after rotation at a non-right angle with expansion are correct. The test was validated against pillow (see PR #2282) """ @@ -961,7 +961,7 @@ def test_empyt_password_1088(): @pytest.mark.enable_socket() def test_old_habibi(): - # this habibi has som multiple characters associated with the h + # this habibi has multiple characters associated with the h reader = PdfReader(SAMPLE_ROOT / "015-arabic/habibi.pdf") txt = reader.pages[0].extract_text() # very odd file # extract from acrobat reader "حَبيبي habibi􀀃􀏲􀎒􀏴􀎒􀎣􀋴 diff --git a/tests/test_reader.py b/tests/test_reader.py index 659520d56..20cb7dd9d 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -719,7 +719,7 @@ def get_dest_pages(x) -> NestedList: def test_decode_permissions(): reader = PdfReader(RESOURCE_ROOT / "crazyones.pdf") base = { - "accessability": False, + "accessability": False, # Do not fix typo, as part of official, but deprecated API. "annotations": False, "assemble": False, "copy": False, @@ -1197,7 +1197,7 @@ def test_outline_missing_title(caplog): @pytest.mark.parametrize( ("url", "name"), [ - # 1st case : the named_dest are stored directly as a dictionnary, PDF1.1 style + # 1st case : the named_dest are stored directly as a dictionary, PDF 1.1 style ( "https://github.com/py-pdf/pypdf/files/9197028/lorem_ipsum.pdf", "lorem_ipsum.pdf", @@ -1207,7 +1207,7 @@ def test_outline_missing_title(caplog): "https://github.com/py-pdf/pypdf/files/11714214/PDF32000_2008.pdf", "PDF32000_2008.pdf", ) - # 3nd case : Dests with Name tree (TODO: Add this case) + # 3rd case : Dests with Name tree (TODO: Add this case) ], ids=["stored_directly", "dest_below_names_with_kids"], ) diff --git a/tests/test_utils.py b/tests/test_utils.py index 2e5faf962..508cfd2a4 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -324,7 +324,7 @@ def test_human_readable_bytes(input_int, expected_output): def test_file_class(): - """File class can be instanciated and string representation is ok.""" + """File class can be instantiated and string representation is ok.""" f = File(name="image.png", data=b"") assert str(f) == "File(name=image.png, data: 0 Byte)" assert repr(f) == "File(name=image.png, data: 0 Byte, hash: 0)" diff --git a/tests/test_workflows.py b/tests/test_workflows.py index 9a4502c46..522327e3e 100644 --- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -67,7 +67,7 @@ def test_basic_features(tmp_path): # add some Javascript to launch the print window on opening this PDF. # the password dialog may prevent the print dialog from being shown, - # comment the the encription lines, if that's the case, to try this out + # comment the encryption lines, if that's the case, to try this out writer.add_js("this.print({bUI:true,bSilent:false,bShrinkToFit:true});") # encrypt your new PDF and add a password @@ -1045,7 +1045,7 @@ def test_cr_with_cm_operation(): Season: SUMMER-B 2023""" in reader.pages[0].extract_text() ) - # currently threre is still a white space on last line missing + # currently there is still a white space on last line missing # so we can not do a full comparison. diff --git a/tests/test_writer.py b/tests/test_writer.py index 15478e7e4..c4ecd5fec 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -1144,7 +1144,7 @@ def test_set_page_label(pdf_file_path): "II", ] - # Tests full lenght with labels assigned at first and last elements + # Tests full length with labels assigned at first and last elements # Tests different labels assigned to consecutive ranges writer = PdfWriter() writer.clone_document_from_reader(reader) @@ -1169,7 +1169,7 @@ def test_set_page_label(pdf_file_path): assert PdfReader(pdf_file_path).page_labels == expected # Tests labels assigned only in the middle - # Tests label assigned to a range already containing labled ranges + # Tests label assigned to a range already containing labelled ranges expected = ["1", "2", "i", "ii", "iii", "iv", "v", "1"] writer = PdfWriter() writer.clone_document_from_reader(reader) @@ -1181,7 +1181,7 @@ def test_set_page_label(pdf_file_path): # Tests labels assigned inside a previously existing range expected = ["1", "2", "i", "a", "b", "A", "1", "1", "2"] - # Ones repeat because user didnt cover the entire original range + # Ones repeat because user did not cover the entire original range writer = PdfWriter() writer.clone_document_from_reader(reader) writer.set_page_label(2, 6, "/r") @@ -1227,7 +1227,7 @@ def test_set_page_label(pdf_file_path): writer.write(pdf_file_path) assert PdfReader(pdf_file_path).page_labels[: len(expected)] == expected - # Tests replacing existing lables + # Tests replacing existing labels expected = ["A", "B", "1", "1", "2"] writer = PdfWriter() writer.clone_document_from_reader(reader)