Skip to main content

Setech Utilities

Python utility library for API clients, logging, and various development tasks.

Installation

Install the package using pip:

pip install setech

Or with virtualenv (recommended):

python -m venv .venv 
source .venv/bin/activate # On Linux/macOS

Extra Dependencies

The following optional dependencies are available:

Extra Description
django Django support (>=5.2, django-crum, django-model-utils)
drf Django REST Framework with full Django stack
dns DNS utilities (dnspython with dnssec, doh, idna support)
dns-redis DNS cache using Redis backend

Install extras:

pip install "setech[django]"      # Django support
pip install "setech[drf]"         # Django REST Framework
pip install "setech[dns]"         # DNS utilities
pip install "setech[dns-redis]"   # DNS cache with Redis

Core Dependencies

The package requires the following core dependencies:

  • httpx2[http2]
  • num2words
  • phonenumberslite
  • pydantic
  • unidecode

Development Setup

The repository uses uv as the package manager and dependency resolver.
Follow these steps to get a fully‑featured development environment with one command.

# 1. Create and activate a virtual environment (recommended)
python -m venv .venv 
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
# 2. Install uv (if you don’t already have it)
curl -LsSf [https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh
# 3. Sync all base, dev and optional extras in a single command
uv sync --dev
# 4. Verify everything is installed
uv run python -m pip list | grep setech

What the --dev flag does

  • Installs the core dependencies listed under [project].
  • Adds the optional extras django, drf and dns‑redis (via setech[... ]).
  • Installs the development tooling (ipython, ruff, mypy, test runners, etc.) from the [dependency-groups] dev section.
  • Resolves transitive dependencies only once, so no duplication occurs.

Tip: If you ever need to refresh the lockfile after a dependency bump, run:

uv sync --dev --upgrade

Example code

API Clients

# integration/client.py
from setech import SyncClient


class LocalClient(SyncClient):
    name = "local"
    _base_url = "https://obligari.serveo.net/ping/local"

    def __init__(self, nonce=None):
        super().__init__(nonce)
        self._session.headers.update(
            {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:123.0) Gecko/20100101 Firefox/123.0"}
        )

    def send_post_ping(self, var1: str, var2: int) -> bool:
        res = self.post("/some-post", json={"variable_one": var1, "second_variable": var2})
        return res.json().get("status")

    def send_put_ping(self, var1: str, var2: int) -> bool:
        res = self.put("/some-put", data={"variable_one": var1, "second_variable": var2})
        return res.json().get("status")

    def send_get_ping(self, var1: str, var2: int) -> bool:
        res = self.get("/some-get", params={"variable_one": var1, "second_variable": var2})
        return res.json().get("status")

    def send_patch_ping(self, var1: str, var2: int) -> bool:
        res = self.put("/some-patch", data=(("variable_one", var1), ("variable_one", var2)))
        return res.json().get("status")

    def send_trace_ping(self, var1: str, var2: int) -> bool:
        res = self.trace("/some-trace", params=(("variable_one", var1), ("variable_one", var2)))
        return res.json().get("status")
# integration/main.py
from integration.client import LocalClient


client = LocalClient()
client.send_post_ping("asd", 123)
client.send_put_ping("asd", 123)
client.send_get_ping("asd", 123)
client.send_patch_ping("asd", 123)
client.send_trace_ping("asd", 123)

Log output

Simple

[14d709e02c0c] Preparing POST request to "https://obligari.serveo.net/ping/local/some-post"
[14d709e02c0c] Sending request with payload=b'{"variable_one": "asd", "second_variable": 123}'
[14d709e02c0c] Response response.status_code=200 str_repr_content='{"status":true,"request_id":62}'
[14d709e02c0c] Preparing GET request to "https://obligari.serveo.net/ping/local/some-get"
[14d709e02c0c] Sending request with payload=None
[14d709e02c0c] Response response.status_code=200 str_repr_content='{"status":true,"request_id":63}'

Structured

{"app": "dev", "level": "DEBUG", "name": "APIClient", "date_time": "2024-03-09 22:59:24", "location": "api_client/client.py:_request:71", "message": "[cfbdadc56f53] Preparing POST request to \"https://obligari.serveo.net/ping/local/some-post\"", "extra_data": {"hooks": {"response": []}, "method": "POST", "url": "https://obligari.serveo.net/ping/local/some-post", "headers": {}, "files": [], "data": [], "json": {"variable_one": "asd", "second_variable": 123}, "params": {}, "auth": null, "cookies": null}}
{"app": "dev", "level": "INFO", "name": "APIClient", "date_time": "2024-03-09 22:59:24", "location": "api_client/client.py:_request:74", "message": "[cfbdadc56f53] Sending request with payload=b'{\"variable_one\": \"asd\", \"second_variable\": 123}'", "extra_data": {"payload": "{\"variable_one\": \"asd\", \"second_variable\": 123}"}}
{"app": "dev", "level": "INFO", "name": "APIClient", "date_time": "2024-03-09 22:59:25", "location": "api_client/client.py:_request:81", "message": "[cfbdadc56f53] Response response.status_code=200 str_repr_content='{\"status\":true,\"request_id\":72}'", "extra_data": {"status_code": 200, "content": "{\"status\":true,\"request_id\":72}"}}
{"app": "dev", "level": "DEBUG", "name": "APIClient", "date_time": "2024-03-09 22:59:25", "location": "api_client/client.py:_request:71", "message": "[cfbdadc56f53] Preparing GET request to \"https://obligari.serveo.net/ping/local/some-get\"", "extra_data": {"hooks": {"response": []}, "method": "GET", "url": "https://obligari.serveo.net/ping/local/some-get", "headers": {}, "files": [], "data": [], "json": null, "params": {"variable_one": "asd", "second_variable": 123}, "auth": null, "cookies": null}}
{"app": "dev", "level": "INFO", "name": "APIClient", "date_time": "2024-03-09 22:59:25", "location": "api_client/client.py:_request:74", "message": "[cfbdadc56f53] Sending request with payload=None", "extra_data": {"payload": "{}"}}
{"app": "dev", "level": "INFO", "name": "APIClient", "date_time": "2024-03-09 22:59:25", "location": "api_client/client.py:_request:81", "message": "[cfbdadc56f53] Response response.status_code=200 str_repr_content='{\"status\":true,\"request_id\":74}'", "extra_data": {"status_code": 200, "content": "{\"status\":true,\"request_id\":73}"}}

django features

Using the setech.django in a Django project

Models

The library ships two abstract base models that can be inherited to get timestamping, UUID and audit fields.

# myapp/models.py
from django.db import models
from setech.django.models import TimeStampedUUIDModel, UserTimeStampedUUIDModel


class Article(TimeStampedUUIDModel):
    title = models.CharField()
    content = models.TextField()


class Comment(UserTimeStampedUUIDModel):
    article = models.ForeignKey(Article, on_delete=models.CASCADE)
    text = models.TextField()

What each base class provides

Base model Fields added Notes
TimeStampedUUIDModel uid, created_at, updated_at UUID (v4 or v7 if available) and timestamps
UserTimeStampedUUIDModel created_by, modified_by Populated automatically from the current request when using Django‑CRUM

Validators

setech.django.validators contains a handful of reusable validator functions that can be dropped straight into Django model fields or form/serializer validations.
They wrap common checks such as phone numbers, personal IDs and MX‑record validation for e‑mail addresses.

# myapp/models.py
from django.db import models
from setech.django.models import TimeStampedUUIDModel
from setech.django.validators import django_phone_number_validator, django_personal_code_validator,
    django_validate_email_mx_domain, validate_image_and_svg_file_extension


class UserProfile(TimeStampedUUIDModel):
    # Phone number in international format, e.g. "+44 20 7946 0958" 
    phone = models.CharField(validators=[django_phone_number_validator])

    # Personal ID (SSN/NRIC/etc.) – the validator automatically uses your
    # `settings.COUNTRY_CODE` (e.g. "LV" for Latvia)
    personal_id = models.CharField(max_length=20, validators=[django_personal_code_validator])

    # Email address – ensures the domain can receive mail
    email = models.EmailField(validators=[django_validate_email_mx_domain])

    # Image file – ensures the file is either image or svg
    picture = models.FileField(validators=[validate_image_and_svg_file_extension])

Customizing the country code

The validators rely on settings.COUNTRY_CODE to decide which format to expect.
Add the following to your Django settings:

# settings.py
from setech.django.constants import Country

...
COUNTRY_CODE = Country.LV  # Latvia, change to your locale

Metadata

Release files for setech 1.8.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for setech 1.8.5
File Size Uploaded Provenance Actions
setech-1.8.5.tar.gz 24.8 kB Without provenance Details for setech-1.8.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for setech 1.8.5
File Interpreter ABI Platform Actions
setech-1.8.5-py3-none-any.whl Python 3 none any Details for setech-1.8.5-py3-none-any.whl

Total release size: 61.1 kB

Release files / setech-1.8.5.tar.gz

Download URL setech-1.8.5.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9d73e22a5e0e45ac0824ab618533ee426871876190695f829e6c4e3cab9cf361
BLAKE2b-256 checksum
How to use checksums
bd94f436a234eec377a76498172758f0e5c0b44a110a4221237abb8c25518799
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / setech-1.8.5-py3-none-any.whl

Download URL setech-1.8.5-py3-none-any.whl
Size 36.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92c4739262fc8d80ad805452c37d1e17198ac1cad022bd14b0388b7eefcf1cd1
BLAKE2b-256 checksum
How to use checksums
de53c43f4ae367054137d955de94248c3cd85de7f36e179fcbb7446aa941ccfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for setech 1.8.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.8.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page