Skip to content

Commit a20e01c

Browse files
authored
chore: run make tidy on api files (#253)
These were excluded from linting when they were autogenerated. We need to tidy these files, otherwise we'll get blocked by our internal deploy pipeline. Note that this should replace the current 0.0.47 candidate.
1 parent 2ace6f5 commit a20e01c

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ check: check-src check-tests check-version
102102
## check-src: runs linters (source only, no tests)
103103
.PHONY: check-src
104104
check-src:
105-
black --line-length 100 ${PACKAGE_NAME} --check --exclude ${PACKAGE_NAME}/api
105+
black --line-length 100 ${PACKAGE_NAME} --check
106106
flake8 ${PACKAGE_NAME}
107107
mypy ${PACKAGE_NAME} --ignore-missing-imports --install-types --non-interactive --implicit-optional
108108

@@ -114,7 +114,7 @@ check-tests:
114114
## tidy: run black
115115
.PHONY: tidy
116116
tidy:
117-
black --line-length 100 ${PACKAGE_NAME} --exclude ${PACKAGE_NAME}/api
117+
black --line-length 100 ${PACKAGE_NAME}
118118
black --line-length 100 test_${PIPELINE_PACKAGE} scripts/smoketest.py
119119

120120
## check-scripts: run shellcheck

prepline_general/api/app.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929
async def http_error_handler(request: Request, e: HTTPException):
3030
logger.error(e.detail)
3131

32-
return JSONResponse(
33-
status_code=e.status_code,
34-
content={"detail": e.detail}
35-
)
32+
return JSONResponse(status_code=e.status_code, content={"detail": e.detail})
3633

3734

3835
# Note(austin) - Convert any other errors to HTTPException
@@ -48,10 +45,7 @@ async def error_handler(request: Request, e: Exception):
4845

4946
logger.error(trace)
5047

51-
error = HTTPException(
52-
status_code=500,
53-
detail=str(e)
54-
)
48+
error = HTTPException(status_code=500, detail=str(e))
5549

5650
return await http_error_handler(request, error)
5751

@@ -85,6 +79,7 @@ def filter(self, record: logging.LogRecord) -> bool:
8579
logging.getLogger("uvicorn.access").addFilter(HealthCheckFilter())
8680
logging.getLogger("uvicorn.access").addFilter(MetricsCheckFilter())
8781

82+
8883
@app.get("/healthcheck", status_code=status.HTTP_200_OK, include_in_schema=False)
8984
def healthcheck(request: Request):
9085
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}

prepline_general/api/general.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,11 @@ def pipeline_api(
277277
# This will raise if the file is encrypted
278278
pdf.metadata
279279
except pypdf.errors.EmptyFileError:
280-
raise HTTPException(
281-
status_code=400, detail=f"File does not appear to be a valid PDF"
282-
)
280+
raise HTTPException(status_code=400, detail="File does not appear to be a valid PDF")
283281
except pypdf.errors.FileNotDecryptedError:
284282
raise HTTPException(
285283
status_code=400,
286-
detail=f"File is encrypted. Please decrypt it with password.",
284+
detail="File is encrypted. Please decrypt it with password.",
287285
)
288286

289287
strategy = (m_strategy[0] if len(m_strategy) else "auto").lower()
@@ -332,19 +330,30 @@ def pipeline_api(
332330
m_skip_infer_table_types[0] if len(m_skip_infer_table_types) else ["pdf", "jpg", "png"]
333331
)
334332

335-
chunking_strategy = (m_chunking_strategy[0].lower() if len(m_chunking_strategy) else None)
333+
chunking_strategy = m_chunking_strategy[0].lower() if len(m_chunking_strategy) else None
336334
chunk_strategies = ["by_title"]
337335
if chunking_strategy and (chunking_strategy not in chunk_strategies):
338336
raise HTTPException(
339-
status_code=400, detail=f"Invalid chunking strategy: {chunking_strategy}. Must be one of {chunk_strategies}"
337+
status_code=400,
338+
detail=f"Invalid chunking strategy: {chunking_strategy}. Must be one of {chunk_strategies}",
340339
)
341-
342-
multipage_sections_str = (m_multipage_sections[0] if len(m_multipage_sections) else "false").lower()
340+
341+
multipage_sections_str = (
342+
m_multipage_sections[0] if len(m_multipage_sections) else "false"
343+
).lower()
343344
multipage_sections = multipage_sections_str == "true"
344345

345-
combine_under_n_chars = (int(m_combine_under_n_chars[0]) if m_combine_under_n_chars and m_combine_under_n_chars[0].isdigit() else 500)
346+
combine_under_n_chars = (
347+
int(m_combine_under_n_chars[0])
348+
if m_combine_under_n_chars and m_combine_under_n_chars[0].isdigit()
349+
else 500
350+
)
346351

347-
new_after_n_chars = (int(m_new_after_n_chars[0]) if m_new_after_n_chars and m_new_after_n_chars[0].isdigit() else 1500)
352+
new_after_n_chars = (
353+
int(m_new_after_n_chars[0])
354+
if m_new_after_n_chars and m_new_after_n_chars[0].isdigit()
355+
else 1500
356+
)
348357

349358
try:
350359
logger.debug(
@@ -477,9 +486,7 @@ def get_validated_mimetype(file):
477486
if content_type not in allowed_mimetypes:
478487
raise HTTPException(
479488
status_code=400,
480-
detail=(
481-
f"File type {content_type} is not supported."
482-
),
489+
detail=(f"File type {content_type} is not supported."),
483490
)
484491

485492
return content_type

0 commit comments

Comments
 (0)