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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 127

[*.py]
indent_style = space
indent_size = 4
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Basic CI setup: Lint with ruff, run tests with pytest
name: Test

on:
pull_request:
push:
branches:
- main

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
- name: Ruff lint
run: uv run ruff check .
- name: Ruff format
run: uv run ruff format --diff .

test:
name: Run tests
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
- run: uv run pytest
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

on:
push:
tags:
# Publish on any tag starting with a `v`, e.g. v1.2.3
- v*

jobs:
pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
# Environment and permissions trusted publishing.
environment:
# Create this environment in the GitHub repository under Settings -> Environments
name: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
- run: uv build
# # Check that basic features work and we didn't miss to include crucial files
# - name: Smoke test (wheel)
# run: uv run --isolated --no-project -p 3.13 --with dist/*.whl tests/smoke_test.py
# - name: Smoke test (source distribution)
# run: uv run --isolated --no-project -p 3.13 --with dist/*.tar.gz tests/smoke_test.py
- run: uv publish --trusted-publishing always
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Python-generated files
__pycache__/
*.py[cod]
*$py.class
.python-version
.env
*.egg-info
dist
dist/
wheels/
build/

dev-notes.md
# Virtual environments
.venv

# Development
dev-notes.md
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.2
hooks:
- id: ruff
- id: ruff-format
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# Virtual Queue | Python SDK
# Virtual Queue Python SDK

A toolset for Virtual Queue integrations in Python
SDK to communicate with Virtual Queue's API in Python projects.

## Development

Some development notes

### Coding style guidelines

The configurations in [.editorconfig](./.editorconfig) and some in [pyproject.toml](./pyptoject.toml) are put in place in order to format and check compliance with [PEP 8](https://pep8.org) (with some exceptions).

[.pre-commit-config.yaml](./.pre-commit-config.yaml) defines a set of hooks to be executed right before each commit so that [ruff](https://docs.astral.sh/ruff/) (a blazingly fast linter and formatter) is called on the changes made.

This project uses [`uv`](https://docs.astral.sh/uv/) as package and project manager. To set it up:

1. Create a virtual environment and install the packages:
```shell
uv sync
```
2. Install the hooks running:
```shell
uvx pre-commit install
```
3. Now on every `git commit` the `pre-commit` hook (inside `.git/hooks/`) will be run.

#### Configuring your editor

To configure your code editor [read `ruff`'s documentation about it](https://docs.astral.sh/ruff/editors/).
49 changes: 35 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,50 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"


[project]
name = "virtualqueue_sdk"
version = "1.0.0"
name = "vqueue-sdk"
version = "0.1.0"
description = "A toolset for Virtual Queue integrations in Python"
readme = "README.md"
authors = [{ name = "Animus Coop.", email = "info@animus.com.ar" }]
license = { file = "LICENSE" }
license = "MIT"
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
keywords = ["tickets", "queue", "async", "events", "high-demand"]
dependencies = [
"requests",
'tomli; python_version < "3.11"',
]
requires-python = ">=3.8"
requires-python = ">=3.10"

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools.package-data]
"vqueue" = ["config.toml"]

[dependency-groups]
dev = [
"pre-commit>=4.2.0",
"pytest>=8.4.1",
"ruff>=0.12.2",
]

[tool.ruff]
line-length = 127

[tool.ruff.lint]
extend-select = [
# Pycodestyle Errors and Warnings
"E",
"W",
# Flake8-bugbear
"B",
# Pyflakes
"F",
# isort
"I",
]
unfixable = ["B"]

[project.urls]
Homepage = "https://github.com/animus-coop/virtual-queue-python-sdk"

[project.scripts]
virtualqueue = "virtualqueue_sdk.__main__:main"
18 changes: 0 additions & 18 deletions requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion src/virtualqueue_sdk/__init__.py

This file was deleted.

25 changes: 0 additions & 25 deletions src/virtualqueue_sdk/__main__.py

This file was deleted.

10 changes: 0 additions & 10 deletions src/virtualqueue_sdk/config.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/virtualqueue_sdk/config.toml

This file was deleted.

39 changes: 0 additions & 39 deletions src/virtualqueue_sdk/queues.py

This file was deleted.

10 changes: 10 additions & 0 deletions src/vqueue/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from . import exceptions, queues, types
from .queues import TokenVerifier

__version__ = "0.1.0"
__all__ = [
"queues",
"exceptions",
"types",
"TokenVerifier",
]
11 changes: 11 additions & 0 deletions src/vqueue/_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from importlib import resources

try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib

with (resources.files("vqueue").joinpath("config.toml")).open("r") as config_file:
_cfg = tomllib.loads(config_file.read())

API_BASE_PATH = _cfg["api"]["base_path"]
2 changes: 2 additions & 0 deletions src/vqueue/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[api]
base_path = "https://app.virtual-queue.com/api/v1/"
30 changes: 30 additions & 0 deletions src/vqueue/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from typing import Optional


class VQueueError(Exception):
"""Virtual Queue SDK exception"""


class VQueueApiError(VQueueError):
"""Exception for API responses with error status"""

def __init__(
self,
code: int,
message: Optional[str],
error_code: Optional[int],
data: Optional[object],
*args,
):
super().__init__(*args)
self.code = code
self.message = message
self.error_code = error_code
self.data = data

def __str__(self) -> str:
return f"VQueue API Error ({self.code}): {self.message or ''}"


class VQueueNetworkError(VQueueError):
"""Exception related to networking errors"""
Loading
Loading