http-response-codes


Namehttp-response-codes JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryA comprehensive Python library providing HTTP status code constants and exceptions
upload_time2025-01-19 12:10:48
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT
keywords codes exceptions http response status
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # HTTP Response Codes

A comprehensive Python library providing HTTP status code constants and exceptions.

[![PyPI version](https://badge.fury.io/py/http-response-codes.svg)](https://badge.fury.io/py/http-response-codes)
[![Python Support](https://img.shields.io/pypi/pyversions/http-response-codes.svg)](https://pypi.org/project/http-response-codes/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

NOTE: This library is still in development and has little actual usage or real
use-cases so far. Indeed, the module api may change considerably - i'll have it
locked down in the next few days. Uploading to PyPI now just to reserve the name
and possibly get some early adopters/feedback

## Overview

`http-response-codes` is a Python library that provides a comprehensive set of
HTTP status codes as exception classes. Each status code is represented by a
class that inherits from `HTTPStatus`, containing the numeric code, message, and
description.

The module covers all standard HTTP status codes in the following categories:

- 1xx: Informational responses (100-102)
- 2xx: Success responses (200-208, 226)
- 3xx: Redirection responses (300-308)
- 4xx: Client error responses (400-431, 451)
- 5xx: Server error responses (500-511)

## Installation

```bash
pip install http-response-codes
```

Or using `uv`:

```bash
uv add http-response-codes
```

## Features

- Complete coverage of HTTP status codes
- Each status code is a proper Python exception class
- Type hints included
- Predefined groups of related status codes
- Intuitive comparison operations
- Detailed descriptions for each status code
- Zero dependencies

## Usage

### Basic Usage

```python
from response_codes import HTTP_404_NOT_FOUND

# Raise as an exception
raise HTTP_404_NOT_FOUND()

# Access status code properties
print(HTTP_404_NOT_FOUND.status_code)  # 404
print(HTTP_404_NOT_FOUND.message)      # "Not Found"
print(HTTP_404_NOT_FOUND.description)  # Detailed description

# Compare with integers
assert HTTP_404_NOT_FOUND == 404
```

### Using Status Code Groups

```python
from response_codes import (
    HTTP_INFORMATIONAL,
    HTTP_SUCCESS,
    HTTP_REDIRECTION,
    HTTP_CLIENT_ERRORS,
    HTTP_SERVER_ERRORS,
)

# Check if a status code is in a group
status_code = 404
if status_code in HTTP_CLIENT_ERRORS:
    print("This is a client error!")
```

## Development

This project uses modern Python tooling:

- `uv` for dependency management
- `ruff` for linting and formatting
- `mypy` for type checking
- `pytest` for testing
- `pre-commit` for git hooks

### Setup Development Environment

Clone the repository:

```bash
git clone https://github.com/seapagan/response-codes.git
cd response-codes
```

Install development dependencies:

```bash
uv sync
```

Install pre-commit hooks:

```bash
pre-commit install
```

### Running Tests

```bash
poe test # or simply run 'pytest'
```

Or in watch mode:

```bash
poe test:watch
```

### Code Quality Checks

```bash
# Run all pre-commit checks
poe pre

# Run mypy type checking
poe mypy

# Run ruff linting
poe ruff

# Run ruff formatting
poe format
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate and adhere to the existing coding style.

## License

This project is licensed under the MIT License - see the LICENSE file for details.

## Author

Created and maintained by [Grant Ramsay](https://github.com/seapagan)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "http-response-codes",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "codes, exceptions, http, response, status",
    "author": null,
    "author_email": "Grant Ramsay <seapagan@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/6b/62/4ab2c5428479a9a0d32bbf94b2a50ebd1e3dedce48d5ff51873626cd6aa8/http_response_codes-0.1.1.tar.gz",
    "platform": null,
    "description": "# HTTP Response Codes\n\nA comprehensive Python library providing HTTP status code constants and exceptions.\n\n[![PyPI version](https://badge.fury.io/py/http-response-codes.svg)](https://badge.fury.io/py/http-response-codes)\n[![Python Support](https://img.shields.io/pypi/pyversions/http-response-codes.svg)](https://pypi.org/project/http-response-codes/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nNOTE: This library is still in development and has little actual usage or real\nuse-cases so far. Indeed, the module api may change considerably - i'll have it\nlocked down in the next few days. Uploading to PyPI now just to reserve the name\nand possibly get some early adopters/feedback\n\n## Overview\n\n`http-response-codes` is a Python library that provides a comprehensive set of\nHTTP status codes as exception classes. Each status code is represented by a\nclass that inherits from `HTTPStatus`, containing the numeric code, message, and\ndescription.\n\nThe module covers all standard HTTP status codes in the following categories:\n\n- 1xx: Informational responses (100-102)\n- 2xx: Success responses (200-208, 226)\n- 3xx: Redirection responses (300-308)\n- 4xx: Client error responses (400-431, 451)\n- 5xx: Server error responses (500-511)\n\n## Installation\n\n```bash\npip install http-response-codes\n```\n\nOr using `uv`:\n\n```bash\nuv add http-response-codes\n```\n\n## Features\n\n- Complete coverage of HTTP status codes\n- Each status code is a proper Python exception class\n- Type hints included\n- Predefined groups of related status codes\n- Intuitive comparison operations\n- Detailed descriptions for each status code\n- Zero dependencies\n\n## Usage\n\n### Basic Usage\n\n```python\nfrom response_codes import HTTP_404_NOT_FOUND\n\n# Raise as an exception\nraise HTTP_404_NOT_FOUND()\n\n# Access status code properties\nprint(HTTP_404_NOT_FOUND.status_code)  # 404\nprint(HTTP_404_NOT_FOUND.message)      # \"Not Found\"\nprint(HTTP_404_NOT_FOUND.description)  # Detailed description\n\n# Compare with integers\nassert HTTP_404_NOT_FOUND == 404\n```\n\n### Using Status Code Groups\n\n```python\nfrom response_codes import (\n    HTTP_INFORMATIONAL,\n    HTTP_SUCCESS,\n    HTTP_REDIRECTION,\n    HTTP_CLIENT_ERRORS,\n    HTTP_SERVER_ERRORS,\n)\n\n# Check if a status code is in a group\nstatus_code = 404\nif status_code in HTTP_CLIENT_ERRORS:\n    print(\"This is a client error!\")\n```\n\n## Development\n\nThis project uses modern Python tooling:\n\n- `uv` for dependency management\n- `ruff` for linting and formatting\n- `mypy` for type checking\n- `pytest` for testing\n- `pre-commit` for git hooks\n\n### Setup Development Environment\n\nClone the repository:\n\n```bash\ngit clone https://github.com/seapagan/response-codes.git\ncd response-codes\n```\n\nInstall development dependencies:\n\n```bash\nuv sync\n```\n\nInstall pre-commit hooks:\n\n```bash\npre-commit install\n```\n\n### Running Tests\n\n```bash\npoe test # or simply run 'pytest'\n```\n\nOr in watch mode:\n\n```bash\npoe test:watch\n```\n\n### Code Quality Checks\n\n```bash\n# Run all pre-commit checks\npoe pre\n\n# Run mypy type checking\npoe mypy\n\n# Run ruff linting\npoe ruff\n\n# Run ruff formatting\npoe format\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate and adhere to the existing coding style.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Author\n\nCreated and maintained by [Grant Ramsay](https://github.com/seapagan)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A comprehensive Python library providing HTTP status code constants and exceptions",
    "version": "0.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/seapagan/response-codes/issues",
        "Documentation": "https://github.com/seapagan/response-codes#readme",
        "Homepage": "https://github.com/seapagan/response-codes",
        "Repository": "https://github.com/seapagan/response-codes"
    },
    "split_keywords": [
        "codes",
        " exceptions",
        " http",
        " response",
        " status"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4b8d63ff6bc02e5f95f4e74f0f34ac0285389acd87b985733154d97bfc594785",
                "md5": "6e14f3831893807a8066f03a4aed5ede",
                "sha256": "fa522eaffd74fdf5b987788e52d08e5849e3067cf91e4a5121ef37c58b8cb6ae"
            },
            "downloads": -1,
            "filename": "http_response_codes-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6e14f3831893807a8066f03a4aed5ede",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 10703,
            "upload_time": "2025-01-19T12:10:46",
            "upload_time_iso_8601": "2025-01-19T12:10:46.348995Z",
            "url": "https://files.pythonhosted.org/packages/4b/8d/63ff6bc02e5f95f4e74f0f34ac0285389acd87b985733154d97bfc594785/http_response_codes-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6b624ab2c5428479a9a0d32bbf94b2a50ebd1e3dedce48d5ff51873626cd6aa8",
                "md5": "9ecd78f0ff3dcf97a2473fd567705fd3",
                "sha256": "2cf7a124326f481bc3fb79582bfc6357177c01c519f682ab60a0cb392dca0a61"
            },
            "downloads": -1,
            "filename": "http_response_codes-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9ecd78f0ff3dcf97a2473fd567705fd3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 47469,
            "upload_time": "2025-01-19T12:10:48",
            "upload_time_iso_8601": "2025-01-19T12:10:48.040922Z",
            "url": "https://files.pythonhosted.org/packages/6b/62/4ab2c5428479a9a0d32bbf94b2a50ebd1e3dedce48d5ff51873626cd6aa8/http_response_codes-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-19 12:10:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "seapagan",
    "github_project": "response-codes",
    "github_not_found": true,
    "lcname": "http-response-codes"
}
        
Elapsed time: 4.00584s