Skip to content

Commit 2fe4a5f

Browse files
committed
Fix syntax errors preventing black formatting
- Fix missing commas in dictionaries (gemini_qa.py) - Fix unterminated docstring in data_retrieval.py - Fix indentation errors in test files (test_api_utils.py, test_integration.py, test_cache_manager.py, test_text_processing.py, test_api_endpoints.py, test_integration_workflow.py) - Update CI lint job to use Docker for black and flake8 (avoids venv setup) All files now pass Python syntax validation and should format correctly with black.
1 parent 187d86a commit 2fe4a5f

File tree

9 files changed

+43
-46
lines changed

9 files changed

+43
-46
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,20 @@ jobs:
129129
- name: Checkout code
130130
uses: actions/checkout@v4
131131

132-
- name: Set up Python
133-
uses: actions/setup-python@v5
134-
with:
135-
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
136-
cache: 'pip'
137-
138-
- name: Install linting dependencies
139-
run: |
140-
python -m pip install --upgrade pip
141-
pip install black>=23.0.0 flake8>=6.0.0
142-
143-
- name: Check code formatting with Black
144-
run: |
145-
black --check --diff app/ tests/ cli.py main.py
146-
147-
- name: Lint with flake8
148-
run: |
149-
flake8 app/ tests/ cli.py main.py --max-line-length=120 --extend-ignore=E203,W503,E501 --exclude=__pycache__,*.pyc
132+
- name: Lint with Black and flake8 using Docker
133+
run: |
134+
docker run --rm \
135+
-v ${{ github.workspace }}:/workspace \
136+
-w /workspace \
137+
python:3.11-slim \
138+
bash -c "
139+
apt-get update -qq && apt-get install -y -qq gcc > /dev/null 2>&1 && \
140+
pip install --quiet --no-cache-dir black>=23.0.0 flake8>=6.0.0 && \
141+
echo '=== Running Black (check mode) ===' && \
142+
black --check --diff app/ tests/ cli.py main.py && \
143+
echo '=== Running flake8 ===' && \
144+
flake8 app/ tests/ cli.py main.py --max-line-length=120 --extend-ignore=E203,W503,E501 --exclude=__pycache__,*.pyc
145+
"
150146
151147
type-check:
152148
name: Type Check

app/models/gemini_qa.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ async def analyze_paper(self, paper_content: Dict[str, str]) -> Dict[str, Union[
356356
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_ONLY_HIGH"},
357357
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_ONLY_HIGH"},
358358
{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_ONLY_HIGH"},
359-
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_ONLY_HIGH"}
359+
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_ONLY_HIGH"},
360360
]
361361
)
362362
analysis_text = response.text.strip()
@@ -640,7 +640,7 @@ def _validate_and_normalize_json(self, parsed_json: Dict) -> Dict:
640640
"condition": {"description": "Unknown", "confidence": 0.0, "status": "ABSENT", "reason_if_missing": "Field not found in analysis", "suggestions_for_curation": "Review paper for condition information"},
641641
"sequencing_type": {"method": "Unknown", "confidence": 0.0, "status": "ABSENT", "reason_if_missing": "Field not found in analysis", "suggestions_for_curation": "Review paper for sequencing method information"},
642642
"taxa_level": {"level": "Unknown", "confidence": 0.0, "status": "ABSENT", "reason_if_missing": "Field not found in analysis", "suggestions_for_curation": "Review paper for taxonomic level information"},
643-
"sample_size": {"size": "Unknown", "confidence": 0.0, "status": "ABSENT", "reason_if_missing": "Field not found in analysis", "suggestions_for_curation": "Review paper for sample size information"}
643+
"sample_size": {"size": "Unknown", "confidence": 0.0, "status": "ABSENT", "reason_if_missing": "Field not found in analysis", "suggestions_for_curation": "Review paper for sample size information"},
644644
}
645645

646646
for field_name, default_structure in required_fields.items():

app/services/data_retrieval.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def _verify_connectivity(self, retries: int = 3) -> None:
6767
logger.warning(f"Unable to reach NCBI E-utilities after retries: {safe_error}. App will continue with limited functionality.")
6868

6969
def _make_request(self, endpoint: str, params: Dict[str, Any], retries: int = None) -> Optional[str]:
70-
"""Make request to NCBI E-utilities with retry logic and rate limiting."""
70+
"""
71+
Make request to NCBI E-utilities with retry logic and rate limiting.
7172
7273
Returns:
7374
Response text or None if all retries failed

tests/test_api_endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Try to import FastAPI-dependent modules, skip tests if not available
88
try:
99
from fastapi.testclient import TestClient
10-
from app.api.app import app
10+
from app.api.app import app
1111
FASTAPI_AVAILABLE = True
1212
except ImportError:
1313
FASTAPI_AVAILABLE = False

tests/test_api_utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
# Try to import FastAPI-dependent modules, skip tests if not available
88
try:
99
from fastapi import FastAPI
10-
from app.api.utils.api_utils import (
11-
extract_taxa,
12-
create_default_field_structure,
13-
validate_field_structure,
14-
create_comprehensive_fallback_analysis,
15-
generate_curation_summary,
16-
get_current_timestamp
17-
)
10+
from app.api.utils.api_utils import (
11+
extract_taxa,
12+
create_default_field_structure,
13+
validate_field_structure,
14+
create_comprehensive_fallback_analysis,
15+
generate_curation_summary,
16+
get_current_timestamp
17+
)
1818
FASTAPI_AVAILABLE = True
1919
except ImportError:
2020
FASTAPI_AVAILABLE = False

tests/test_cache_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Import CacheManager directly to avoid import chain issues
1111
try:
1212
# Try direct import first
13-
from app.services.cache_manager import CacheManager
13+
from app.services.cache_manager import CacheManager
1414
except ImportError:
1515
# If that fails, try importing the module directly
1616
import sys

tests/test_integration.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
# Try to import FastAPI-dependent modules, skip tests if not available
1010
try:
11-
from fastapi.testclient import TestClient
12-
from app.api.app import app
11+
from fastapi.testclient import TestClient
12+
from app.api.app import app
1313
FASTAPI_AVAILABLE = True
1414
except ImportError:
1515
FASTAPI_AVAILABLE = False
@@ -82,7 +82,7 @@ def test_cache_and_retrieval_workflow(self):
8282
"""Test that caching and retrieval work together."""
8383
# Import CacheManager directly to avoid import chain issues
8484
try:
85-
from app.services.cache_manager import CacheManager
85+
from app.services.cache_manager import CacheManager
8686
except ImportError:
8787
# Fallback: use importlib to load directly from file
8888
import sys
@@ -202,7 +202,7 @@ class TestTextProcessingIntegration:
202202
def test_text_cleaning_and_processing_workflow(self):
203203
"""Test that text cleaning and processing work together."""
204204
try:
205-
from app.utils.text_processing import AdvancedTextProcessor
205+
from app.utils.text_processing import AdvancedTextProcessor
206206
except ImportError:
207207
pytest.skip("torch not available")
208208

@@ -223,7 +223,7 @@ def test_text_cleaning_and_processing_workflow(self):
223223
def test_text_encoding_decoding_workflow(self):
224224
"""Test that encoding and decoding work together."""
225225
try:
226-
from app.utils.text_processing import AdvancedTextProcessor
226+
from app.utils.text_processing import AdvancedTextProcessor
227227
except ImportError:
228228
pytest.skip("torch not available")
229229

@@ -301,7 +301,7 @@ def test_cache_error_handling(self):
301301
"""Test that cache errors are handled gracefully."""
302302
# Import CacheManager directly to avoid import chain issues
303303
try:
304-
from app.services.cache_manager import CacheManager
304+
from app.services.cache_manager import CacheManager
305305
except ImportError:
306306
# Fallback: use importlib to load directly from file
307307
import sys
@@ -359,7 +359,7 @@ def test_data_flow_from_api_to_cache(self):
359359
"""Test data flow from API request through to cache."""
360360
# Import CacheManager directly to avoid import chain issues
361361
try:
362-
from app.services.cache_manager import CacheManager
362+
from app.services.cache_manager import CacheManager
363363
except ImportError:
364364
# Fallback: use importlib to load directly from file
365365
import sys
@@ -417,7 +417,7 @@ async def test_async_cache_operations(self):
417417
"""Test that async cache operations work correctly."""
418418
# Import CacheManager directly to avoid import chain issues
419419
try:
420-
from app.services.cache_manager import CacheManager
420+
from app.services.cache_manager import CacheManager
421421
except ImportError:
422422
# Fallback: use importlib to load directly from file
423423
import sys

tests/test_integration_workflow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
# Try to import services, skip tests if FastAPI not available
1111
try:
1212
from fastapi import FastAPI
13-
from app.services.web_scraper import WebScraperService
14-
from app.services.image_processor import ImageProcessorService
15-
from app.services.converter_service import ConverterService
16-
from app.services.vector_store_service import VectorStoreService
17-
from app.utils.chunking import ChunkingService
13+
from app.services.web_scraper import WebScraperService
14+
from app.services.image_processor import ImageProcessorService
15+
from app.services.converter_service import ConverterService
16+
from app.services.vector_store_service import VectorStoreService
17+
from app.utils.chunking import ChunkingService
1818
FASTAPI_AVAILABLE = True
1919
except ImportError:
2020
FASTAPI_AVAILABLE = False

tests/test_text_processing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
# Try to import torch and the module, skip tests if not available
77
try:
8-
import torch
9-
from app.utils.text_processing import AdvancedTextProcessor
8+
import torch
9+
from app.utils.text_processing import AdvancedTextProcessor
1010
TORCH_AVAILABLE = True
1111
except ImportError:
1212
TORCH_AVAILABLE = False

0 commit comments

Comments
 (0)