Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build GitHub Pages
on:
push:
branches:
- main
paths:
- 'docs/**'
- 'mkdocs.yml'
- 'suthing/**'
workflow_dispatch:

permissions:
contents: write
pages: write
id-token: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.17"
- name: Install dependencies
run: |
uv sync --group docs

- name: Configure Git
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"

- name: Deploy documentation
run: |-
uv run mkdocs gh-deploy --force
20 changes: 20 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.17"
- name: Install dependencies
run: |
uv sync --group dev
- uses: pre-commit/action@v3.0.1
23 changes: 23 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: pytest

on:
pull_request:
push:
branches: [main]

jobs:
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.17"
- name: Install dependencies
run: |
uv sync --group dev
- name: Run pytest
run: |-
source .venv/bin/activate
pytest test
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@ serialize/

# mypy
.dmypy.json
dmypy.json
dmypy.json

site/
public/
18 changes: 5 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@ fail_fast: false

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
rev: v0.11.7
hooks:
- id: ruff
args: [--fix, --ignore, E722, --exclude, "__init__.py"]
- id: ruff-format
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args: ["-rn", "-sn", "--output-format=colorized", "--errors-only", "--jobs", "4", "--rcfile=.pylintrc"]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
rev: 6.0.1
hooks:
- id: isort
args:
- --line-length=79
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.15.0
hooks:
- id: mypy
args: [--show-error-codes]
additional_dependencies: [types-requests, types-python-dateutil, types-waitress, types-PyYAML, pandas-stubs]
additional_dependencies: [types-requests, types-python-dateutil, types-waitress, types-PyYAML, pandas-stubs, types-setuptools]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
Expand All @@ -46,7 +38,7 @@ repos:
- id: pretty-format-toml
args: [--autofix]
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
rev: v0.24.2
hooks:
- id: toml-sort
args: [-ia]
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"python.testing.pytestArgs": [
"test"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.autoTestDiscoverOnSaveEnabled": true,
"svg.preview.background": "transparent"
}
191 changes: 191 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,197 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# Changelog - Connection Configuration Library

## Version 0.4.0 (2025-05-01)

### Breaking Changes

1. **Connection Type Access Changed**
- Before: `connection_kind.config_class()` (method call)
- After: `connection_kind.config_class` (property access)

Migration:
```python
# Before
config_class = ConnectionKind.ARANGO.config_class()

# After
config_class = ConnectionKind.ARANGO.config_class
```

2. **Connection Configuration Creation**
- Before: Direct class instantiation with `hosts` parameter
- After: Use `url` parameter or factory with more flexible options

Migration:
```python
# Before
config = ArangoConnectionConfig(hosts="http://localhost:8529", cred_name="root", cred_pass="password")

# After
config = ArangoConnectionConfig(url="http://localhost:8529", username="root", password="password")
# Or using factory
config = ConfigFactory.create_config({
"db_type": "arango",
"url": "http://localhost:8529",
"username": "root",
"password": "password"
})
```

3. **Renamed Credential Parameters**
- Before: `cred_name`, `cred_pass`
- After: `username`, `password` (with backward compatibility)

Migration:
```python
# Before
config = Neo4jConnectionConfig(cred_name="neo4j", cred_pass="password")

# After (preferred)
config = Neo4jConnectionConfig(username="neo4j", password="password")
# Old params still work but are deprecated
config = Neo4jConnectionConfig(cred_name="neo4j", cred_pass="password") # Still works
```

- Before: `ip_addr`
- After: `hostname`

- Before: WSGIConfig.host
- After: WSGIConfig.listen_addr


Migration:
```python
# Before
config = Neo4jConnectionConfig(cred_name="neo4j", cred_pass="password")

# After (preferred)
config = Neo4jConnectionConfig(username="neo4j", password="password")
# Old params still work but are deprecated
config = Neo4jConnectionConfig(cred_name="neo4j", cred_pass="password") # Still works
```


4. **URL Parsing Changes**
- Before: Custom parsing with string operations
- After: Standard library `urlparse` for robust URL handling

Migration:
```python
# Before - URL components were extracted with custom string operations
# After - Just use the url parameter and components are automatically extracted
config = WSGIConfig(url="http://localhost:5000/api/v1")
print(config.protocol) # "http"
print(config.ip_addr) # "localhost"
print(config.port) # "5000"
print(config.path) # "/api/v1"
```

5. **Changed `hosts` Parameter to `url`**
- Before: Primary URL parameter was named `hosts`
- After: Primary URL parameter is named `url`

Migration:
```python
# Before
config = ProtoConnectionConfig(hosts="http://localhost:8080")

# After
config = ProtoConnectionConfig(url="http://localhost:8080")
```

### New Features

1. **Direct URL-based Configuration**
```python
# Create config with just a URL
config = ConfigFactory.create_config(url="neo4j://neo4j:password@localhost:7687/mydb")
```

2. **Improved Factory with Type Inference**
```python
# Factory now tries to infer connection type from URL
config = ConfigFactory.create_config(url="http://localhost:8529/_db/mydb") # Will infer ArangoDB if "arango" is in URL
```

3. **Expanded File Handling**
```python
# Load configuration from JSON or YAML
config = ConfigFactory.create_config(path="config.json")
config = ConfigFactory.create_config(path="config.yaml")

# Save configuration
from suthing import FileHandle
FileHandle.save(config.__dict__, "config.json")
```

4. **First-Class Support for Connection Base Class**
```python
# Use the factory with automatic type detection
from suthing import ConnectionConfig
config_dict = {"db_type": "neo4j", "url": "neo4j://localhost:7687"}
config = ConnectionConfig.from_dict(config_dict)
```

### Other Improvements

1. **Better Type Annotations**
```python
from typing import Dict, Optional

# Types are now properly annotated
def process_config(config: ConnectionConfig) -> Dict[str, Optional[str]]:
return {
"type": config.connection_type.value if config.connection_type else None,
"url": config.url,
"database": getattr(config, "database", None)
}
```

2. **Enhanced Error Handling**
```python
# More specific error messages
try:
config = ConnectionConfig.from_dict({"db_type": "unknown"})
except ValueError as e:
print(e) # "Connection type 'unknown' not supported. Should be one of: ['arango', 'neo4j', 'wsgi']"
```


## Migration Guide

### Step 2: Update URL Parameters
```python
# Before
config = Neo4jConnectionConfig(hosts="http://localhost:7687", cred_name="neo4j", cred_pass="pass")

# After
config = Neo4jConnectionConfig(url="http://localhost:7687", username="neo4j", password="pass")
```

### Step 3: Update Factory Usage
```python
# Before
config = ConfigFactory.create_config(dict_like={"db_type": "arango", "hosts": "http://localhost:8529"})

# After
config = ConfigFactory.create_config(dict_like={"db_type": "arango", "url": "http://localhost:8529"})
# Or more directly
config = ConfigFactory.create_config(url="http://localhost:8529")
```

### Step 4: Update Connection Type Access
```python
# Before
config_class = db_type.config_class()

# After
config_class = db_type.config_class
```


## [0.3.0] - 2025-01-15
- published on pypi

Expand Down
Loading