chore: apply ruff formatting and fix whitespace issues
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -16,4 +16,3 @@ updates:
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
open-pull-requests-limit: 5
|
||||
|
||||
|
||||
@@ -42,5 +42,3 @@ EXPOSE 8000
|
||||
|
||||
# Default command
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def upload_with_rclone(self, file_path: str, destination: str):
|
||||
# Try to get a public link if possible
|
||||
try:
|
||||
link_cmd = ["rclone", "link", "--config", rclone_config_path, f"{destination}/{filename}"]
|
||||
link_result = subprocess.run(link_cmd, capture_output=True, text=True)
|
||||
link_result = subprocess.run(link_cmd, capture_output=True, text=True, check=False)
|
||||
public_url = link_result.stdout.strip() if link_result.returncode == 0 else None
|
||||
except (subprocess.SubprocessError, OSError) as e:
|
||||
logger.warning(f"[{task_id}] Failed to get public link for {filename}: {str(e)}")
|
||||
|
||||
@@ -108,4 +108,3 @@ Text extraction logs to check for `extracted_text`:
|
||||
- `process_with_azure_document_intelligence` - Azure OCR processing
|
||||
|
||||
Both may contain extracted text in the `detail` field when `status = 'success'`.
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
@@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
@@ -158,7 +158,7 @@ Library.
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
@@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
@@ -267,7 +267,7 @@ Library will still fall under Section 6.)
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
@@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
@@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
@@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
@@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
|
||||
@@ -6,7 +6,7 @@ Create Date: 2026-02-11
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
from typing import Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
@@ -6,7 +6,7 @@ Create Date: 2026-02-11
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
from typing import Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
@@ -6,7 +6,7 @@ Create Date: 2026-02-12
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
from typing import Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
+3
-1
@@ -124,10 +124,12 @@ ignore = [
|
||||
"PLR0911", # Too many return statements
|
||||
"PLR2004", # Magic value comparison
|
||||
"PLW0603", # Global statement
|
||||
"B008", # Function call in default argument (FastAPI Depends pattern)
|
||||
"B904", # Raise without from (overly strict for error handlers)
|
||||
]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"tests/*" = ["S101", "S110", "B017"] # Allow assert, try-except-pass, assert-raises-exception in tests
|
||||
"tests/*" = ["S101", "S110", "B017", "F841", "B007", "E402"] # Allow assert, try-except-pass, assert-raises-exception, unused vars, unused loop vars, module imports not at top in tests
|
||||
|
||||
# pytest configuration
|
||||
[tool.pytest.ini_options]
|
||||
|
||||
@@ -244,9 +244,9 @@ class TestAzureDocumentIntelligenceIntegration:
|
||||
assert len(result.content) > 10, f"OCR text too short: {result.content[:50]}"
|
||||
|
||||
# Verify the generated text is recognizable
|
||||
assert "Acme" in result.content or "Invoice" in result.content, (
|
||||
f"OCR text does not contain expected keywords: {result.content[:200]}"
|
||||
)
|
||||
assert (
|
||||
"Acme" in result.content or "Invoice" in result.content
|
||||
), f"OCR text does not contain expected keywords: {result.content[:200]}"
|
||||
|
||||
# Retrieve the searchable PDF output
|
||||
operation_id = poller.details["operation_id"]
|
||||
@@ -602,9 +602,9 @@ class TestFullOCRMetadataPipeline:
|
||||
|
||||
# The generated invoice should be classified reasonably
|
||||
doc_type = metadata["document_type"].lower()
|
||||
assert any(kw in doc_type for kw in ("invoice", "rechnung", "bill")), (
|
||||
f"Unexpected document_type: {metadata['document_type']}"
|
||||
)
|
||||
assert any(
|
||||
kw in doc_type for kw in ("invoice", "rechnung", "bill")
|
||||
), f"Unexpected document_type: {metadata['document_type']}"
|
||||
finally:
|
||||
os.unlink(pdf_path)
|
||||
|
||||
|
||||
@@ -83,9 +83,9 @@ class TestSplitPdfBySize:
|
||||
# that can cause files to exceed the target size by ~20-50%. We allow 1.5x (50%) margin.
|
||||
PDF_OVERHEAD_MULTIPLIER = 1.5
|
||||
for split_file in split_files:
|
||||
assert os.path.getsize(split_file) <= max_size * PDF_OVERHEAD_MULTIPLIER, (
|
||||
f"Split file {split_file} should respect size limit (with PDF overhead allowance)"
|
||||
)
|
||||
assert (
|
||||
os.path.getsize(split_file) <= max_size * PDF_OVERHEAD_MULTIPLIER
|
||||
), f"Split file {split_file} should respect size limit (with PDF overhead allowance)"
|
||||
|
||||
# Cleanup split files
|
||||
for split_file in split_files:
|
||||
|
||||
@@ -142,9 +142,9 @@ def test_x_frame_options_valid_value(client):
|
||||
x_frame_value = response.headers["X-Frame-Options"]
|
||||
valid_values = ["DENY", "SAMEORIGIN"]
|
||||
# Note: ALLOW-FROM is deprecated in modern browsers; use CSP frame-ancestors instead
|
||||
assert x_frame_value in valid_values or x_frame_value.startswith("ALLOW-FROM"), (
|
||||
f"Invalid X-Frame-Options value: {x_frame_value}"
|
||||
)
|
||||
assert x_frame_value in valid_values or x_frame_value.startswith(
|
||||
"ALLOW-FROM"
|
||||
), f"Invalid X-Frame-Options value: {x_frame_value}"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
|
||||
@@ -305,9 +305,9 @@ class TestWebDAVIntegration:
|
||||
response = requests.get(file_url, auth=(webdav_server["username"], webdav_server["password"]), timeout=10)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(response.content) == 1024 * 1024, (
|
||||
f"File size mismatch: expected 1MB, got {len(response.content)} bytes"
|
||||
)
|
||||
assert (
|
||||
len(response.content) == 1024 * 1024
|
||||
), f"File size mismatch: expected 1MB, got {len(response.content)} bytes"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
|
||||
Reference in New Issue
Block a user