semvec/pypi-packages huggingface dataset:
django-validate-decorators 0.1.0
Useful decorators for Django views


# Django Decorators

This Python package provides a collection of decorators for Django views to streamline handling of request types and parameters.

## Installation

You can install the package using pip:

```shell
pip install django-validate-decorators
```

## Usage

Import the desired decorators from the package and apply them to your view functions:

```python
from django.http import HttpResponse
from decorators import pass_only_get, pass_json_body

@pass_only_get
def my_view(request, name: str, age: int):
    # Your view logic
    # Use name and age here
    return HttpResponse('Hello World.')
```

## Features

- `pass_only_get`: Ensures that the view only processes GET requests.
- `pass_only_post`: Ensures that the view only processes POST requests.
- `pass_only_post_and_get`: Ensures that the view only processes POST and GET requests.
- `pass_json_body`: Parses and validates JSON request bodies.

## Config

You can pass parameters to check types and values of request parameters. The following parameters are available:

- `check_type=False`: Checks parameters type, if set True. (Default: False), it throws `TypeError` if the type is not matched.
- `check_value=HttpResponse`: Checks parameters type if set HttpResponse. It throws `HttpResponse` if the value is not matched.
- `check_value=Exception`: You can customize your own exception class. It throws your exception if the value is not matched.


## Contributing

Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change.

## License

This project is licensed under the MIT License - see the LICENSE file for details.
mypy-einsum 1.0.0
Mypy plugin for NumPy/Jax/PyTorch einsum operations
Requires Python: >=3.9

# MyPy Type Checking for NumPy/Jax/PyTorch Einsum Operations

`mypy_einsum` is a [Mypy](https://mypy.readthedocs.io/) plugin for type checking [`np.einsum`](https://numpy.org/doc/stable/reference/generated/numpy.einsum.html), [`jax.numpy.einsum`](https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.einsum.html), and [`torch.einsum`](https://pytorch.org/docs/stable/generated/torch.einsum.html) operations.

The Einstein summation convention can be used to compute many multi-dimensional, linear algebraic array operations. `einsum` provides a succinct way of representing these.

However, since `einsum` equations are passed as a string, it is very easy to overlook typos or other bugs as linters are unable to help.
`mypy_einsum` is a [Mypy](https://mypy.readthedocs.io/) plugin that that is able to statically verify the correctness of `einsum` equations with needing to execute the code.

## Installation

`mypy_einsum` can be installed with [`pip`](https://pip.pypa.io/):

```shell
pip install mypy-einsum
```

## Setup

To enable the plugin, add it to you projects [Mypy configuration file](https://mypy.readthedocs.io/en/stable/config_file.html).
Usually `mypy.ini`:

```ini
[mypy]
plugins = mypy_einsum
```

or `pyproject.toml`:

```toml
[tool.mypy]
plugins = ["mypy_einsum"]
```

## Example

Can you spot the 🐛 without running the code?

```python
import numpy as np

a = np.arange(9).reshape(3, 3)

np.einsum("ik,kj->ij", a)
```

`mypy_einsum` will catch it for you:

```shell
❯ mypy example.py --pretty
example.py:5: error: Number of einsum subscripts must be equal to the
number of operands.  [einsum]
    np.einsum("ik,kj->ij", a)
              ^~~~~~~~~~~
Found 1 error in 1 file (checked 1 source file)
```

After fixing it `mypy` will succeed 🎉:

```python
np.einsum("ik,kj->ij", a, a)
```

```bash
❯ mypy example.py
Success: no issues found in 1 source file
```

## Supported Operations

- [`np.einsum`](https://numpy.org/doc/stable/reference/generated/numpy.einsum.html)
- [`np.einsum_path`](https://numpy.org/doc/stable/reference/generated/numpy.einsum_path.html)
- [`jax.numpy.einsum`](https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.einsum.html)
- [`jax.numpy.einsum_path`](https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.einsum_path.html)
- [`torch.einsum`](https://pytorch.org/docs/stable/generated/torch.einsum.html)

## Reporting Issues and Contributing

`mypy_einsum` aims to never raise warnings for valid `einsum` operations. If you encounter a warning that you believe is incorrect, or think `mypy_einsum` is not reporting an error please let us know. Contributions are very welcome!