Skip to main content

Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects.

Project description

Logo

Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects ✨

Continuous Integration Package version Supported Python versions Pydantic v2

Requirements

A recent and currently supported version of Python (right now, Python supports versions 3.9 and above).

As Pagidantic is based on Pydantic, it requires them. They will be automatically installed when you install Pagidantic.

Notes: we support only Pydantic v2. If you are using Pydantic v1, you can install it using pip install pagidantic==1.1.0

Installation

You can add Pagidantic in a few easy steps. First of all, install the dependency:

$ pip install pagidantic

---> 100%

Successfully installed pagidantic

Usage

from pagidantic import pagidantic

# Generate a list here: https://json-generator.com/
object_list = [...]  # list of objects


pagination = pagidantic(object_list, page_limit=2, start_page=0)

# get current returned page
def get_current_page():
    return pagination.response


# get next pageg
def get_next_page():
    return pagination.get_next()


# get previous page
def get_previous_page():
    return pagination.get_previous()


# get page by number
def get_page_by_number():
    return pagination.get_page_response(page_number=0)


# get total pages
def get_total_pages():
    return pagination.total_pages


# Count total objects
def count_total_objects():
    return pagination.total

Development 🚧

Setup environment 📦

You should create a virtual environment and activate it:

python -m venv venv/
source venv/bin/activate

And then install the development dependencies:

# Install dependencies
pip install -e .[test,lint]

Run tests 🌝

You can run all the tests with:

bash scripts/test.sh

Format the code 🍂

Execute the following command to apply pre-commit formatting:

bash scripts/format.sh

Execute the following command to apply mypy type checking:

bash scripts/lint.sh

License

This project is licensed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pagidantic-2.0.0.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pagidantic-2.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file pagidantic-2.0.0.tar.gz.

File metadata

  • Download URL: pagidantic-2.0.0.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pagidantic-2.0.0.tar.gz
Algorithm Hash digest
SHA256 71acf10ca3c81455d545df7bcd63508f4bef35676248ae0655569b0f5d568e5a
MD5 ba5fb884f6ac26cad6203fa297fb0283
BLAKE2b-256 3d99d468eb66e87614595a4fa9aedecb95ea1d7abb1b4abb4f4ee52d22a50105

See more details on using hashes here.

File details

Details for the file pagidantic-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: pagidantic-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pagidantic-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 926a119261bc1c40d812e5b6e8e65a3fb2ead3719b8d50654a0f42f47768af91
MD5 b88c1acb7c3c2addaea9d01faa4cd306
BLAKE2b-256 dfad20619b5feeefdfd1701ab7da432f41584ff6b2fc5c0c9c6e32bf9de3082c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page