# Wardy Utils

**Wardy Utils** is a collection of general-purpose utilities designed to simplify and enhance your Python scripting experience. This library provides reusable components that can be integrated into your projects to save time and effort.

## Features

### HTTP Utilities

- **`http`**: A high-level HTTP client built on top of `httpx` and `hishel`, setting some caching and timeout comment settings.

## Installation

To install Wardy Utils, use pip:

```bash
pip install wardy-utils
```

## Usage

### HTTP Client Example

```python
from wardy_utils.web import cached_client

client = cached_client()
response = client.get("https://example.com")
print(response.text)
```

Convenience singletons live in `wardy_utils.web` if you want ready-made instances without wiring:

- `sync_client`: default sync client.
- `sync_force_client`: sync client that ignores origin cache headers.
- `async_client`: default async client.
- `async_force_client`: async client that ignores origin cache headers.

Environment overrides for the HTTP client:

| Variable | Description | Default |
| --- | --- | --- |
| `WARDY_UTILS_CACHE_DIR` | Directory for the sqlite cache file. | In-memory |
| `WARDY_UTILS_CACHE_FILENAME` | Filename for the sqlite cache file when a cache directory is set. | `wardy-utils-cache.sqlite` |
| `WARDY_UTILS_CACHE_TTL` | Cache TTL in seconds. | `1800` |
| `WARDY_UTILS_TIMEOUT` | Request timeout in seconds. | `45` |
| `WARDY_UTILS_FORCE_CACHE` | If truthy, ignore origin cache-control headers. | Disabled |
| `WARDY_UTILS_HTTP2` | Enable or disable HTTP/2. | Enabled |

Proxy behaviour: the client inherits proxy settings from standard `http_proxy`, `https_proxy`, and `all_proxy` environment variables, so you can point traffic via your organisation's proxy without code changes.

## Requirements

- Python 3.13.3 or higher

## Contributing

Contributions are welcome! Run the test suite with coverage via:

```bash
pytest --cov=src --cov-report=xml
```

Feel free to open issues or submit pull requests to improve the library.

## License

This project is licensed under the MIT License.

## Author

Created by **Wardy**  
Email: [wardy3+gitlab@gmail.com](mailto:wardy3+gitlab@gmail.com)
