Skip to content

Commit bd50ec1

Browse files
committed
👌 IMPROVE: Test with validations
1 parent ad1d990 commit bd50ec1

15 files changed

+453
-620
lines changed

CONTRIBUTING.md

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ Thank you for your interest in contributing to the Langbase Python SDK! We welco
2323
python3 -m venv .venv
2424
source .venv/bin/activate # On Windows: .venv\Scripts\activate
2525
```
26+
### Note:
27+
Check version of pip
28+
```bash
29+
pip --version
30+
```
31+
**If it's pip 21.3 or lower, you need to upgrade it.**
32+
```bash
33+
pip install --upgrade pip
34+
```
2635
2736
3. **Install the package in development mode**
2837
```bash
@@ -43,7 +52,7 @@ Thank you for your interest in contributing to the Langbase Python SDK! We welco
4352
4453
**IMPORTANT**: All code must pass quality checks before committing. Run these commands:
4554
46-
### 1. Format Your Code
55+
### Format Your Code
4756
```bash
4857
# Auto-format with Black (required)
4958
black langbase/ tests/ examples/
@@ -52,20 +61,6 @@ black langbase/ tests/ examples/
5261
isort langbase/ tests/ examples/
5362
```
5463
55-
### 2. Run Linting Checks
56-
```bash
57-
# Run Ruff linter (auto-fixes many issues)
58-
ruff check --fix langbase/ tests/
59-
60-
# Check without auto-fix to see what changed
61-
ruff check langbase/ tests/
62-
```
63-
64-
### 3. Type Checking
65-
```bash
66-
# Run mypy for type checking
67-
mypy langbase/ --strict
68-
```
6964
7065
### 4. Run Tests
7166
```bash
@@ -94,8 +89,6 @@ Before pushing your changes, ensure:
9489
9590
- [ ] ✅ Code is formatted with `black`
9691
- [ ] ✅ Imports are sorted with `isort`
97-
- [ ] ✅ No linting errors from `ruff`
98-
- [ ] ✅ Type checking passes with `mypy`
9992
- [ ] ✅ All tests pass with `pytest`
10093
- [ ] ✅ New features have tests
10194
- [ ] ✅ New features have type hints
@@ -162,29 +155,16 @@ Use Google-style docstrings:
162155
def my_function(param1: str, param2: int) -> bool:
163156
"""
164157
Brief description of function.
165-
158+
166159
Args:
167160
param1: Description of param1
168161
param2: Description of param2
169-
162+
170163
Returns:
171164
Description of return value
172-
173-
Raises:
174-
ValueError: When invalid input provided
175-
"""
176165
...
177166
```
178167
179-
### Error Handling
180-
Use specific exceptions and helpful error messages:
181-
```python
182-
if not api_key:
183-
raise ValueError(
184-
"API key is required. Set LANGBASE_API_KEY environment variable "
185-
"or pass api_key parameter."
186-
)
187-
```
188168
189169
## Testing Guidelines
190170
@@ -200,7 +180,7 @@ def test_pipe_run_with_invalid_name_raises_error(langbase_client):
200180
"""Test that running a pipe with invalid name raises appropriate error."""
201181
with pytest.raises(NotFoundError) as exc_info:
202182
langbase_client.pipes.run(name="non-existent-pipe")
203-
183+
204184
assert "404" in str(exc_info.value)
205185
```
206186
@@ -213,4 +193,4 @@ def test_pipe_run_with_invalid_name_raises_error(langbase_client):
213193
214194
## License
215195
216-
By contributing, you agree that your contributions will be licensed under the MIT License.
196+
By contributing, you agree that your contributions will be licensed under the MIT License.

langbase/langbase.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,17 @@ class Langbase:
2626
including pipes, memories, tools, threads, and utilities.
2727
"""
2828

29-
def __init__(
30-
self, api_key: Optional[str] = None, base_url: str = "https://api.langbase.com"
31-
):
29+
def __init__(self, api_key: str = "", base_url: str = "https://api.langbase.com"):
3230
"""
3331
Initialize the Langbase client.
3432
3533
Args:
3634
api_key: The API key for authentication. If not provided, it will be read
3735
from the LANGBASE_API_KEY environment variable.
3836
base_url: The base URL for the API.
39-
40-
Raises:
41-
ValueError: If no API key is provided and LANGBASE_API_KEY is not set.
4237
"""
43-
self.api_key = api_key
4438
self.base_url = base_url
39+
self.api_key = api_key
4540

4641
self.request = Request({"api_key": self.api_key, "base_url": self.base_url})
4742

langbase/primitives/memories.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ def upload(
8888
8989
Returns:
9090
Upload response
91-
92-
Raises:
93-
ValueError: If document type is unsupported
94-
APIError: If the upload fails
9591
"""
9692
try:
9793
# Get signed URL for upload

langbase/primitives/pipes.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ def run(
121121
122122
Returns:
123123
Run response or stream
124-
125-
Raises:
126-
ValueError: If neither name nor API key is provided
127124
"""
128125
if not name and not api_key:
129126
msg = "Either pipe name or API key is required"

langbase/types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,10 @@ class PipeListResponse(TypedDict):
663663
class LangbaseOptions(TypedDict, total=False):
664664
"""Options for initializing Langbase client."""
665665

666-
api_key: str
667-
base_url: Literal["https://api.langbase.com", "https://eu-api.langbase.com"]
666+
api_key: str # Required
667+
base_url: Literal[
668+
"https://api.langbase.com", "https://eu-api.langbase.com"
669+
] # Optional
668670

669671

670672
# Protocol for file-like objects

langbase/utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ def convert_document_to_request_files(
2727
2828
Returns:
2929
Dictionary for use with requests.post(files=...)
30-
31-
Raises:
32-
ValueError: If the document type is not supported
33-
FileNotFoundError: If the document path doesn't exist
3430
"""
3531
files: Dict[str, Union[Tuple[str, bytes, ContentType], Tuple[None, str], str]] = {}
3632

mypy.ini

Lines changed: 0 additions & 35 deletions
This file was deleted.

ruff.toml

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)