Skip to content

Commit 03c9e07

Browse files
authored
Merge pull request #1 from alvseven/test
remove context wrapper
2 parents 94ba6a1 + bd68344 commit 03c9e07

27 files changed

Lines changed: 265 additions & 213 deletions

.github/workflows/lint.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,4 @@ jobs:
2323
- name: Lint check (ruff)
2424
run: |
2525
uv run ruff format --check
26-
uv run ruff check .
27-
28-
- name: Typecheck
29-
run: |
30-
uv run pyright
31-
uv run mypy .
26+
uv run ruff check .

.github/workflows/main.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@ permissions:
99

1010
jobs:
1111
lint:
12-
uses: ./.github/workflows/lint.yaml
12+
uses: ./.github/workflows/lint.yaml
13+
14+
typecheck:
15+
needs: lint
16+
uses: ./.github/workflows/typecheck.yaml
17+
18+
publish:
19+
needs: typecheck
20+
uses: ./.github/workflows/publish.yaml

.github/workflows/publish.yaml

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,62 @@
1-
name: Publish
1+
name: Publish to PyPI
22

33
on:
4+
pull_request:
5+
branches:
6+
- main
47
push:
5-
branches: [main]
6-
7-
concurrency: ${{ github.workflow }}-${{ github.ref }}
8+
branches:
9+
- main
10+
workflow_dispatch:
811

912
permissions:
1013
contents: write
14+
pull-requests: write
1115
id-token: write
1216

17+
concurrency: ${{ github.workflow }}-${{ github.ref }}
18+
1319
jobs:
14-
build-and-publish:
20+
release-please:
1521
runs-on: ubuntu-latest
22+
outputs:
23+
release_created: ${{ steps.release.outputs.release_created }}
24+
tag_name: ${{ steps.release.outputs.tag_name }}
1625
steps:
17-
- uses: actions/checkout@v4
26+
- uses: googleapis/release-please-action@v4
27+
id: release
1828
with:
19-
fetch-depth: 0
20-
21-
- uses: actions/setup-python@v5
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
release-type: python
31+
package-name: alves-blindpay
32+
bump-minor-pre-major: true
33+
bump-patch-for-minor-pre-major: false
34+
include-v-in-tag: true
35+
extra-files: |
36+
src/alves-blindpay/__init__.py
37+
38+
publish:
39+
needs: release-please
40+
if: ${{ needs.release-please.outputs.release_created }}
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
2245
with:
23-
python-version: "3.12"
46+
ref: ${{ needs.release-please.outputs.tag_name }}
2447

25-
- uses: astral-sh/setup-uv@v4
48+
- name: Install uv
49+
uses: astral-sh/setup-uv@v4
2650

27-
- name: Sync build deps
28-
run: uv sync
51+
- name: Build package
52+
run: uv build
2953

30-
- name: Build (sdist + wheel)
31-
run: uv run python -m build
54+
- name: Check package
55+
run: uvx twine check dist/*
3256

33-
- name: Publish to PyPI (Trusted Publishing)
34-
uses: pypa/[email protected]
35-
with:
36-
skip-existing: true
57+
- name: Publish to PyPI
58+
env:
59+
UV_PUBLISH_USERNAME: __token__
60+
UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
61+
run: |
62+
uv publish

.github/workflows/typecheck.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Type Check
2+
on:
3+
workflow_call:
4+
5+
jobs:
6+
typecheck:
7+
name: Run type checking
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Setup Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.12"
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v4
19+
20+
- name: Sync dev deps
21+
run: uv sync --group dev
22+
23+
- name: Type check
24+
run: uv run pyright
25+
26+
- name: Type check
27+
run: uv run mypy .
28+

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "1.0.0"
3+
}

README.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,6 @@ async def main():
5151
asyncio.run(main())
5252
```
5353

54-
## Using with Context Manager
55-
56-
```python
57-
import asyncio
58-
from blindpay import BlindPay
59-
60-
async def main():
61-
async with BlindPay(
62-
api_key="your-api-key",
63-
instance_id="your-instance-id"
64-
) as client:
65-
# Your code here
66-
response = await client.quotes["create"](
67-
bank_account_id="bank-account-id",
68-
currency_type="receiver",
69-
request_amount=1000,
70-
cover_fees=False,
71-
# ... other fields
72-
)
73-
print(response)
74-
75-
asyncio.run(main())
76-
```
77-
7854
## Resources
7955

8056
The SDK provides access to the following resources:

examples/get_available_rails.py

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from blindpay import BlindPay, BlindPaySync
1111

1212

13-
async def async_example():
13+
async def async_example() -> None:
1414
print("=== Async Example ===\n")
1515

1616
client = BlindPay(
@@ -55,7 +55,7 @@ async def async_example():
5555
print(f" • {detail['label']} ({detail['key']}) - {required}")
5656

5757

58-
def sync_example():
58+
def sync_example() -> None:
5959
print("\n\n=== Sync Example ===\n")
6060

6161
client = BlindPaySync(
@@ -100,69 +100,7 @@ def sync_example():
100100
print(f" • {detail['label']} ({detail['key']}) - {required}")
101101

102102

103-
def context_manager_example():
104-
"""Example using context manager (auto-closes connection)"""
105-
print("\n\n=== Context Manager Example ===\n")
106-
107-
with BlindPaySync(
108-
api_key="your_api_key_here",
109-
instance_id="your_instance_id_here",
110-
) as client:
111-
rails_response = client.available.get_rails()
112-
113-
if rails_response["error"]:
114-
print(f"Error: {rails_response['error']['message']}")
115-
elif rails_response["data"]:
116-
rails = rails_response["data"]
117-
print(f"Available rails: {[r['value'] for r in rails]}")
118-
else:
119-
print("No data returned")
120-
121-
# Connection is automatically closed when exiting the context
122-
123-
124-
def error_handling_example():
125-
"""Example with proper error handling"""
126-
print("\n\n=== Error Handling Example ===\n")
127-
128-
try:
129-
client = BlindPaySync(
130-
api_key="your_api_key_here",
131-
instance_id="your_instance_id_here",
132-
)
133-
134-
response = client.available.get_rails()
135-
136-
# Check for errors
137-
if response["error"]:
138-
error_msg = response["error"]["message"]
139-
print(f"❌ API Error: {error_msg}")
140-
# Handle the error appropriately
141-
return
142-
143-
# Process the successful response
144-
rails = response["data"]
145-
if rails is None:
146-
print("⚠️ No data returned")
147-
return
148-
149-
print(f"✅ Success! Retrieved {len(rails)} rails")
150-
151-
# Do something with the data
152-
for rail in rails:
153-
print(f" - {rail['label']}: {rail['value']}")
154-
155-
except Exception as e:
156-
print(f"❌ Unexpected error: {e}")
157-
# Handle unexpected errors
158-
159-
160103
if __name__ == "__main__":
161104
asyncio.run(async_example())
162105

163106
sync_example()
164-
165-
context_manager_example()
166-
167-
error_handling_example()
168-

py.typed

Whitespace-only changes.

pyproject.toml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "blindpay"
2+
name = "alves-blindpay"
33
version = "1.0.0"
44
description = "Official Python SDK for the Blindpay API — Global payments infrastructure"
55
readme = "README.md"
@@ -25,19 +25,23 @@ classifiers = [
2525
Homepage = "https://github.com/blindpaylabs/blindpay-python"
2626
Repository = "https://github.com/blindpaylabs/blindpay-python"
2727
Documentation = "https://api.blindpay.com/reference"
28+
"Bug Tracker" = "https://github.com/blindpaylabs/blindpay-python/issues"
2829

2930
[build-system]
3031
requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"]
3132
build-backend = "hatchling.build"
3233

34+
[tool.hatch.version]
35+
path = "src/blindpay/__init__.py"
36+
3337
[tool.hatch.build]
34-
include = ["src/*", "README.md", "LICENSE", "pyproject.toml"]
38+
include = ["src/*", "README.md", "LICENSE", "py.typed"]
3539

3640
[tool.hatch.build.targets.wheel]
3741
packages = ["src/blindpay"]
3842

3943
[tool.hatch.build.targets.sdist]
40-
include = ["/src/*", "/README.md", "/LICENSE", "/pyproject.toml"]
44+
include = ["/src", "/README.md", "/LICENSE", "/pyproject.toml", "/py.typed"]
4145

4246
[tool.hatch.metadata.hooks.fancy-pypi-readme]
4347
content-type = "text/markdown"
@@ -75,11 +79,7 @@ known-first-party = ["blindpay"]
7579

7680
[tool.ruff.lint.per-file-ignores]
7781
"examples/*.py" = ["T201"]
78-
79-
[tool.pyright]
80-
typeCheckingMode = "strict"
81-
pythonVersion = "3.12"
82-
exclude = [".venv", ".git", "examples"]
82+
"test_*.py" = ["T201"]
8383

8484
[tool.mypy]
8585
pretty = true
@@ -97,3 +97,7 @@ disallow_untyped_calls = true
9797
disallow_subclassing_any = true
9898
disallow_incomplete_defs = true
9999
disallow_untyped_decorators = true
100+
exclude = [
101+
"^test_.*\\.py$",
102+
"^examples/",
103+
]

pyrightconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"include": ["src"],
3+
"exclude": [".venv", ".git", "examples/**", "**/__pycache__", "test_*.py"],
4+
"typeCheckingMode": "strict",
5+
"pythonVersion": "3.12",
6+
"executionEnvironments": [
7+
{
8+
"root": "src/blindpay/resources",
9+
"reportArgumentType": "error",
10+
"reportTypedDictNotRequiredAccess": "warning",
11+
"reportMissingTypeArgument": "error",
12+
},
13+
{
14+
"root": "src/blindpay",
15+
}
16+
]
17+
}
18+
19+

0 commit comments

Comments
 (0)