Skip to content

Commit a646ea1

Browse files
committed
added __all__ declarations
1 parent 1c9040d commit a646ea1

18 files changed

+21
-41
lines changed

.github/workflows/dev-cicd.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ jobs:
1515
- name: Check out repo
1616
uses: actions/checkout@v4
1717
- name: Set up Python
18-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v5
1919
with:
2020
python-version: "3.10"
21+
cache: "pip"
2122
- name: Install pre-commit
2223
run: pip install pre-commit
2324
- name: Run pre-commit
24-
run: pre-commit run --all-files
25+
run: pre-commit run --all-files --show-diff-on-failure
2526

2627
build:
2728
runs-on: ubuntu-latest
@@ -46,9 +47,10 @@ jobs:
4647
docker-images: true
4748
swap-storage: true
4849
- name: Set up Python
49-
uses: actions/setup-python@v4
50+
uses: actions/setup-python@v5
5051
with:
5152
python-version: ${{ matrix.python-version }}
53+
cache: "pip"
5254
- name: Install Tesseract OCR
5355
run: |
5456
sudo apt-get update

datafog/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from typing import Optional
88

9+
910
class DataFogException(Exception):
1011
"""
1112
Base exception for DataFog SDK.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from .spacy_pii_annotator import SpacyPIIAnnotator
2+
3+
__all__ = ["SpacyPIIAnnotator"]

datafog/processing/text_processing/spacy_pii_annotator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def annotate(self, text: str) -> Dict[str, List[str]]:
6363
if len(text) > MAXIMAL_STRING_SIZE:
6464
text = text[:MAXIMAL_STRING_SIZE]
6565
doc = self.nlp(text)
66-
classified_entities: Dict[str, List[str]] = {label: [] for label in PII_ANNOTATION_LABELS}
66+
classified_entities: Dict[str, List[str]] = {
67+
label: [] for label in PII_ANNOTATION_LABELS
68+
}
6769
for ent in doc.ents:
6870
if ent.label_ in classified_entities:
6971
classified_entities[ent.label_].append(ent.text)

datafog/services/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from .image_service import ImageService
22
from .spark_service import SparkService
33
from .text_service import TextService
4+
5+
__all__ = ["ImageService", "SparkService", "TextService"]

datafog/services/image_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def __init__(self, use_donut: bool = False, use_tesseract: bool = True):
9595
PytesseractProcessor() if self.use_tesseract else None
9696
)
9797

98-
async def download_images(self, urls: List[str]) -> List[Union[Image.Image, BaseException]]:
98+
async def download_images(
99+
self, urls: List[str]
100+
) -> List[Union[Image.Image, BaseException]]:
99101
tasks = [
100102
asyncio.create_task(self.downloader.download_image(url)) for url in urls
101103
]

notes/story-1.8-tkt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
– Delete committed artifacts, extend .gitignore.
22
– Add CI jobs for lint (ruff/flake8), mypy, tests, bench.
3-
– Pin exact versions in requirements*.txt; keep full dependency set.
4-
– Update docs / README badges.
3+
– Pin exact versions in requirements\*.txt; keep full dependency set.
4+
– Update docs / README badges.

run_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
import os
43
import subprocess
54
import sys
65

scripts/compare_benchmarks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22

33
import json
4-
import os
54
import sys
65

76

scripts/fixed_text_service.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
"""
55

66
import asyncio
7-
from typing import Dict, List, Optional, Union
7+
from typing import Dict, List, Union
88

99
from datafog.processing.text_processing.regex_annotator.regex_annotator import (
10-
AnnotationResult,
1110
RegexAnnotator,
1211
Span,
1312
)

tests/benchmark_text_service.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
"""Benchmark tests for comparing regex vs spaCy performance in TextService."""
22

33
import time
4-
from typing import Dict, List
54

65
import pytest
76

8-
from datafog.processing.text_processing.regex_annotator import RegexAnnotator
9-
from datafog.processing.text_processing.spacy_pii_annotator import SpacyPIIAnnotator
107
from datafog.services.text_service import TextService
118

129

tests/test_cli_smoke.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55

66
import os
77
import tempfile
8-
from pathlib import Path
9-
from unittest.mock import patch
108

119
import pytest
1210
from typer.testing import CliRunner
1311

1412
from datafog.client import app
15-
from datafog.models.anonymizer import Anonymizer, AnonymizerType
16-
from datafog.models.spacy_nlp import SpacyAnnotator
1713

1814

1915
@pytest.fixture

tests/test_client.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
from unittest.mock import MagicMock, patch
1+
from unittest.mock import patch
22

33
import pytest
44
from typer.testing import CliRunner
55

66
from datafog.client import app
77
from datafog.models.annotator import AnnotationResult, AnnotatorMetadata
8-
from datafog.models.anonymizer import (
9-
AnonymizationResult,
10-
Anonymizer,
11-
AnonymizerType,
12-
HashType,
13-
)
8+
from datafog.models.anonymizer import AnonymizationResult, AnonymizerType, HashType
149
from datafog.models.common import EntityTypes
1510

1611
runner = CliRunner()

tests/test_donut_lazy_import.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import asyncio
2-
import importlib
31
import sys
42
from unittest.mock import patch
53

6-
import pytest
7-
84
from datafog.services.image_service import ImageService
95

106

tests/test_main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
import json
32
import logging
43
import re

tests/test_ocr_integration.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
"""
77

88
import io
9-
import json
10-
import os
119
from unittest.mock import patch
1210

1311
import pytest

tests/test_regex_annotator.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
from typing import Dict, List, Tuple
2-
31
import pytest
42

53
# Import the regex annotator module
64
from datafog.processing.text_processing.regex_annotator import (
75
AnnotationResult,
86
RegexAnnotator,
9-
Span,
107
)
118

129

tests/test_text_service_integration.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
"""Integration tests for TextService engine selection functionality."""
22

3-
from unittest.mock import MagicMock, patch
4-
53
import pytest
64

7-
from datafog.processing.text_processing.regex_annotator.regex_annotator import (
8-
RegexAnnotator,
9-
)
10-
from datafog.processing.text_processing.spacy_pii_annotator import SpacyPIIAnnotator
115
from datafog.services.text_service import TextService
126

137

0 commit comments

Comments
 (0)