Skip to content

Commit 15d6e8f

Browse files
Complete Python library test suite and improvements
Fixed Tests (20/20 passing) Test Coverage increased to 72% Added CI/CD workflow Fixed configure() bugs
1 parent f30b65e commit 15d6e8f

5 files changed

Lines changed: 402 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.9", "3.10", "3.11", "3.12"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e ".[dev]"
28+
29+
- name: Run tests with coverage
30+
run: |
31+
pytest --cov=datasetiq --cov-report=term --cov-report=xml
32+
33+
- name: Upload coverage to Codecov
34+
uses: codecov/codecov-action@v4
35+
with:
36+
file: ./coverage.xml
37+
fail_ci_if_error: false
38+
39+
lint:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Set up Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: "3.11"
49+
50+
- name: Install dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
pip install black ruff
54+
55+
- name: Check code formatting with Black
56+
run: black --check datasetiq tests
57+
58+
- name: Lint with Ruff
59+
run: ruff check datasetiq tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ examples/*.xlsx
6969

7070
# Cache directory (user-specific, don't commit)
7171
# Note: appdirs creates this in user directory, not in project
72+
TRUSTED_PUBLISHING_SETUP.md

datasetiq/config.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import os
88
from typing import Optional
99

10+
# Sentinel value to distinguish "not provided" from "explicitly None"
11+
_NOT_SET = object()
12+
1013

1114
class Config:
1215
"""Global configuration state."""
@@ -41,15 +44,15 @@ def __init__(self):
4144

4245

4346
def configure(
44-
api_key: Optional[str] = None,
45-
base_url: Optional[str] = None,
46-
timeout: Optional[tuple] = None,
47-
max_retries: Optional[int] = None,
48-
max_retry_sleep: Optional[int] = None,
49-
anon_max_pages: Optional[int] = None,
50-
data_cache_ttl: Optional[int] = None,
51-
search_cache_ttl: Optional[int] = None,
52-
enable_cache: Optional[bool] = None,
47+
api_key: Optional[str] = _NOT_SET,
48+
base_url: Optional[str] = _NOT_SET,
49+
timeout: Optional[tuple] = _NOT_SET,
50+
max_retries: Optional[int] = _NOT_SET,
51+
max_retry_sleep: Optional[int] = _NOT_SET,
52+
anon_max_pages: Optional[int] = _NOT_SET,
53+
data_cache_ttl: Optional[int] = _NOT_SET,
54+
search_cache_ttl: Optional[int] = _NOT_SET,
55+
enable_cache: Optional[bool] = _NOT_SET,
5356
) -> None:
5457
"""
5558
Configure DataSetIQ client settings.
@@ -73,23 +76,24 @@ def configure(
7376
... data_cache_ttl=3600 # 1 hour cache
7477
... )
7578
"""
76-
if api_key is not None:
79+
if api_key is not _NOT_SET:
7780
_config.api_key = api_key
78-
if base_url is not None:
79-
_config.base_url = base_url.rstrip("/")
80-
if timeout is not None:
81+
if base_url is not _NOT_SET:
82+
if base_url is not None:
83+
_config.base_url = base_url.rstrip("/")
84+
if timeout is not _NOT_SET:
8185
_config.timeout = timeout
82-
if max_retries is not None:
86+
if max_retries is not _NOT_SET:
8387
_config.max_retries = max_retries
84-
if max_retry_sleep is not None:
88+
if max_retry_sleep is not _NOT_SET:
8589
_config.max_retry_sleep = max_retry_sleep
86-
if anon_max_pages is not None:
90+
if anon_max_pages is not _NOT_SET:
8791
_config.anon_max_pages = anon_max_pages
88-
if data_cache_ttl is not None:
92+
if data_cache_ttl is not _NOT_SET:
8993
_config.data_cache_ttl = data_cache_ttl
90-
if search_cache_ttl is not None:
94+
if search_cache_ttl is not _NOT_SET:
9195
_config.search_cache_ttl = search_cache_ttl
92-
if enable_cache is not None:
96+
if enable_cache is not _NOT_SET:
9397
_config.enable_cache = enable_cache
9498

9599

0 commit comments

Comments
 (0)