Skip to content

Commit 4108b23

Browse files
authored
Merge pull request #9 from vzucher/master
BrightData Python SDK V2 2.0 🐍
2 parents 9cc9d88 + aac4394 commit 4108b23

File tree

222 files changed

+30686
-5202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+30686
-5202
lines changed

.github/workflows/lint.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.9"
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install black ruff mypy
23+
pip install types-requests aiohttp python-dotenv tldextract aiolimiter pydantic
24+
25+
- name: Run black
26+
run: black --check src tests
27+
28+
- name: Run ruff
29+
run: ruff check src tests
30+
31+
- name: Run mypy (non-blocking)
32+
run: mypy src --ignore-missing-imports || echo "⚠️ mypy found type issues (non-blocking)"
33+
continue-on-error: true

.github/workflows/publish.yml

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,30 @@
1-
name: Build and Publish
1+
name: Publish to PyPI
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
74
release:
85
types: [published]
9-
workflow_dispatch:
106

117
jobs:
12-
build:
8+
publish:
139
runs-on: ubuntu-latest
14-
1510
steps:
1611
- uses: actions/checkout@v4
17-
1812
- name: Set up Python
19-
uses: actions/setup-python@v4
13+
uses: actions/setup-python@v5
2014
with:
21-
python-version: '3.8'
15+
python-version: "3.9"
2216

23-
- name: Install dependencies
17+
- name: Install build dependencies
2418
run: |
2519
python -m pip install --upgrade pip
2620
pip install build twine
27-
pip install -r requirements.txt
2821
2922
- name: Build package
3023
run: python -m build
3124

32-
- name: Upload build artifacts
33-
uses: actions/upload-artifact@v4
34-
with:
35-
name: dist-files
36-
path: dist/
37-
3825
- name: Publish to PyPI
39-
if: github.event_name == 'release'
4026
env:
4127
TWINE_USERNAME: __token__
4228
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
43-
run: |
44-
twine upload dist/*
29+
run: twine upload dist/*
4530

46-
test-install:
47-
runs-on: ubuntu-latest
48-
needs: build
49-
50-
steps:
51-
- name: Set up Python
52-
uses: actions/setup-python@v4
53-
with:
54-
python-version: '3.8'
55-
56-
- name: Download build artifacts
57-
uses: actions/download-artifact@v4
58-
with:
59-
name: dist-files
60-
path: dist/
61-
62-
- name: Test wheel installation
63-
run: |
64-
pip install dist/*.whl
65-
python -c "import brightdata; print('✅ Package imported successfully')"

.github/workflows/test.yml

Lines changed: 38 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,50 @@
1-
name: Tests
1+
name: Test
22

33
on:
44
push:
5-
branches: [ main, develop ]
5+
branches: [main, develop]
66
pull_request:
7-
branches: [ main ]
8-
schedule:
9-
- cron: '0 2 * * *'
7+
branches: [main, develop]
108

119
jobs:
1210
test:
1311
runs-on: ubuntu-latest
1412
strategy:
1513
matrix:
16-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
17-
18-
steps:
19-
- uses: actions/checkout@v4
20-
21-
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v4
23-
with:
24-
python-version: ${{ matrix.python-version }}
25-
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install -r requirements.txt
30-
pip install pytest pytest-cov
31-
32-
- name: Test package import
33-
run: |
34-
python -c "import brightdata; print('Import successful')"
35-
36-
- name: Run tests
37-
run: |
38-
python -m pytest tests/ -v --cov=brightdata --cov-report=xml
39-
40-
- name: Upload coverage to Codecov
41-
if: matrix.python-version == '3.8'
42-
uses: codecov/codecov-action@v3
43-
with:
44-
file: ./coverage.xml
14+
python-version: ["3.9", "3.10", "3.11", "3.12"]
4515

46-
test-pypi-package:
47-
runs-on: ubuntu-latest
48-
if: github.event_name == 'schedule'
49-
strategy:
50-
matrix:
51-
python-version: ['3.8', '3.11']
52-
5316
steps:
54-
- uses: actions/checkout@v4
55-
56-
- name: Set up Python ${{ matrix.python-version }}
57-
uses: actions/setup-python@v4
58-
with:
59-
python-version: ${{ matrix.python-version }}
60-
61-
- name: Install PyPI package
62-
run: |
63-
python -m pip install --upgrade pip
64-
pip install brightdata-sdk
65-
pip install pytest
66-
67-
- name: Test PyPI package import
68-
run: |
69-
python -c "import brightdata; print('PyPI package import successful')"
70-
python -c "from brightdata import bdclient; print('bdclient import successful')"
71-
72-
- name: Test PyPI package basic functionality
73-
run: |
74-
python -c "
75-
import sys
76-
from brightdata import bdclient, __version__
77-
print(f'PyPI package version: {__version__}')
78-
79-
# Test that validation works (accept any validation error as success)
80-
try:
81-
client = bdclient(api_token='test_token_too_short')
82-
print('WARNING: No validation error - this might indicate an issue')
83-
except Exception as e:
84-
print(f'Validation error caught: {str(e)[:100]}...')
85-
print('PyPI package validation working correctly')
86-
87-
# Test basic client creation with disabled auto-zone creation
88-
try:
89-
client = bdclient(api_token='test_token_123456789', auto_create_zones=False)
90-
print('Client creation successful')
91-
92-
# Test that basic methods exist
93-
methods = ['scrape', 'search', 'download_content']
94-
for method in methods:
95-
if hasattr(client, method):
96-
print(f'Method {method} exists')
97-
else:
98-
print(f'Method {method} missing (might be version difference)')
99-
100-
except Exception as e:
101-
print(f'ERROR: Client creation failed: {e}')
102-
sys.exit(1)
103-
104-
print('PyPI package basic functionality test completed')
105-
"
106-
107-
- name: Test PyPI package compatibility
108-
run: |
109-
python -c "
110-
print('Running PyPI package compatibility tests...')
111-
112-
# Test import compatibility
113-
try:
114-
from brightdata import bdclient, __version__
115-
from brightdata.exceptions import ValidationError
116-
print('Core imports working')
117-
except ImportError as e:
118-
print(f'ERROR: Import failed: {e}')
119-
exit(1)
120-
121-
# Test that client requires token
122-
try:
123-
client = bdclient() # Should fail without token
124-
print('WARNING: Client created without token - unexpected')
125-
except Exception:
126-
print('Token requirement validated')
127-
128-
print('PyPI package compatibility tests completed')
129-
"
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: Lint with Ruff
30+
run: |
31+
ruff check src/ tests/
32+
33+
- name: Format check with Black
34+
run: |
35+
black --check src/ tests/
36+
37+
- name: Type check with mypy (non-blocking)
38+
run: |
39+
mypy src/ --ignore-missing-imports || echo "⚠️ mypy found type issues (non-blocking)"
40+
continue-on-error: true
41+
42+
- name: Test with pytest
43+
run: |
44+
pytest tests/ -v --cov=src --cov-report=xml --cov-report=term
45+
46+
- name: Upload coverage
47+
uses: codecov/codecov-action@v3
48+
with:
49+
file: ./coverage.xml
50+
fail_ci_if_error: false

0 commit comments

Comments
 (0)