Accept most of ruff's delinting

This commit is contained in:
James R. Barlow
2023-04-14 00:45:34 -07:00
parent b7eb93eb79
commit 9b8d14d16e
47 changed files with 121 additions and 172 deletions
+6 -7
View File
@@ -3,12 +3,10 @@
from __future__ import annotations
import os
import platform
import sys
from pathlib import Path
from subprocess import PIPE, CompletedProcess, run
from typing import List
from subprocess import CompletedProcess, run
import pytest
@@ -71,10 +69,13 @@ def outtxt(tmp_path) -> Path:
@pytest.fixture(scope="function")
def no_outpdf(tmp_path) -> Path:
"""This just documents the fact that a test is not expected to produce
"""Document fact that a test is not expected to produce output.
This just documents the fact that a test is not expected to produce
output. Unfortunately an assertion failure inside a test fixture produces
an error rather than a test failure, so no testing is done. It's up to
the test to confirm that no output file was created."""
the test to confirm that no output file was created.
"""
return tmp_path / 'no_output.pdf'
@@ -110,7 +111,6 @@ def run_ocrmypdf_api(input_file: Path, output_file: Path, *args) -> ExitCode:
The return code must always be checked or the test may declare a failure
to be pass.
"""
api_args = [str(input_file), str(output_file)] + [
str(arg) for arg in args if arg is not None
]
@@ -128,7 +128,6 @@ def run_ocrmypdf(
If an exception is thrown this fact will be returned as part of the result
text and return code rather than exception objects.
"""
p_args = (
[sys.executable, '-m', 'ocrmypdf']
+ [str(arg) for arg in args if arg is not None]
+1 -1
View File
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 James R. Barlow
# SPDX-License-Identifier: MIT
"""Tesseract bad utf8
"""Tesseract bad utf8.
In some cases, some versions of Tesseract can output binary gibberish or data
that is not UTF-8 compatible, so we are forced to check that we can convert it
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2022 James R. Barlow
# SPDX-License-Identifier: MIT
"""Cache output of tesseract to speed up test suite
"""Cache output of tesseract to speed up test suite.
The cache is keyed by by the input test file The input arguments are slugged
into a hideous filename that more or less represents them literally. Joined
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2022 James R. Barlow
# SPDX-License-Identifier: MIT
"""Tesseract no-op/fixed rotate plugin
"""Tesseract no-op/fixed rotate plugin.
To quickly run tests where getting OCR output is not necessary and we want to test
the rotation pipeline.
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2022 James R. Barlow
# SPDX-License-Identifier: MIT
"""Tesseract no-op plugin
"""Tesseract no-op plugin.
To quickly run tests where getting OCR output is not necessary.
-2
View File
@@ -3,8 +3,6 @@
from __future__ import annotations
import pytest
from ocrmypdf.helpers import check_pdf
+1 -1
View File
@@ -4,7 +4,7 @@
from __future__ import annotations
import os
from subprocess import PIPE, run
from subprocess import run
import pytest
-1
View File
@@ -6,7 +6,6 @@ from __future__ import annotations
from unittest.mock import patch
import pikepdf
import pytest
import ocrmypdf
-2
View File
@@ -5,8 +5,6 @@ from __future__ import annotations
import logging
import pytest
from ocrmypdf._sync import configure_debug_logging
+1 -1
View File
@@ -446,7 +446,7 @@ def test_linearized_pdf_and_indirect_object(resources, outpdf):
def test_very_high_dpi(resources, outpdf):
"Checks for a Decimal quantize error with high DPI, etc"
"Checks for a Decimal quantize error with high DPI, etc."
check_ocrmypdf(
resources / '2400dpi.pdf',
outpdf,
-11
View File
@@ -231,17 +231,6 @@ def test_xml_metadata_preserved(
'pdf:keywords',
]
acquired_properties = ['dc:format']
might_change_properties = [
'dc:date',
'pdf:pdfversion',
'pdf:Producer',
'xmp:CreateDate',
'xmp:ModifyDate',
'xmp:MetadataDate',
'xmp:CreatorTool',
'xmpMM:DocumentId',
'xmpMM:DnstanceId',
]
# Cleanup messy data structure
# Top level is key-value mapping of namespaces to keys under namespace,
-2
View File
@@ -3,8 +3,6 @@
from __future__ import annotations
import pytest
from ocrmypdf import quality as qual
+6 -4
View File
@@ -11,12 +11,13 @@ from os import fspath
import img2pdf
import pikepdf
import pytest
from PIL import Image, ImageChops
from reportlab.pdfgen.canvas import Canvas
from ocrmypdf._exec import ghostscript
from ocrmypdf._plugin_manager import get_plugin_manager
from ocrmypdf.helpers import IMG2PDF_KWARGS, Resolution
from ocrmypdf.pdfinfo import PdfInfo
from PIL import Image, ImageChops
from reportlab.pdfgen.canvas import Canvas
from .conftest import check_ocrmypdf, run_ocrmypdf
@@ -152,13 +153,14 @@ def test_autorotate_threshold(threshold, op, comparison_threshold, resources, ou
def test_rotated_skew_timeout(resources, outpdf):
"""This document contains an image that is rotated 90 into place with a
"""Check rotated skew timeout.
This document contains an image that is rotated 90 into place with a
/Rotate tag and intentionally skewed by altering the transformation matrix.
This tests for a bug where the combination of preprocessing and a tesseract
timeout produced a page whose dimensions did not match the original's.
"""
input_file = resources / 'rotated_skew.pdf'
in_pageinfo = PdfInfo(input_file)[0]
+1 -4
View File
@@ -4,13 +4,10 @@
from __future__ import annotations
import os
import sys
from pathlib import Path
from subprocess import DEVNULL, PIPE, Popen, run
from subprocess import DEVNULL, PIPE, run
import pytest
from ocrmypdf.exceptions import ExitCode
from ocrmypdf.helpers import check_pdf
from .conftest import run_ocrmypdf
+1 -2
View File
@@ -8,14 +8,13 @@ from os import fspath
from unittest.mock import patch
import pytest
from PIL import Image
from ocrmypdf._exec import unpaper
from ocrmypdf._plugin_manager import get_parser_options_plugins
from ocrmypdf._validation import check_options
from ocrmypdf.exceptions import ExitCode, MissingDependencyError
from .conftest import check_ocrmypdf, have_unpaper, ocrmypdf_exec, run_ocrmypdf
from .conftest import check_ocrmypdf, have_unpaper, run_ocrmypdf
# pylint: disable=redefined-outer-name