semvec/pypi-packages huggingface dataset:
easy-exceptions 1.0.2
Throw and catch named exceptions without creating a class first
License: MIT
Keywords: exceptions

[![CircleCI](https://circleci.com/gh/Cruuncher/EasyExceptions/tree/master.svg?style=shield)](https://circleci.com/gh/Cruuncher/EasyExceptions/tree/master) 
[![Coverage Status](https://coveralls.io/repos/github/Cruuncher/EasyExceptions/badge.svg?branch=master)](https://coveralls.io/github/Cruuncher/EasyExceptions?branch=master)
[![PyPi](https://img.shields.io/badge/pypi-v1.0.2-blue)](https://pypi.org/project/easy-exceptions/1.0.2/)

# EasyExceptions
Throw and catch named exceptions without creating a class first. The goal of this project is to make working with named exceptions simpler. It's often a huge overhead of work to create named exceptions in a separate file before being able to throw them to nicely be caught. 

## Installation 

    pip install easy-exceptions

## Usage
    from easy_exceptions import EasyException
    try:
        raise EasyException('NamedException')('TEST MESSAGE')
    except EasyException('NamedException') as e:
        print("Caught this specific exception without having to define it!")

EasyExceptions even supports using a custom parent class instead of the base Exception. This is because APIs often use a custom exception class for rendering error messages. All you have to do in this case is pass that parent class to EasyException and instantiate it the way you always would. For example: 

    from easy_exceptions import EasyException 
    from api.exceptions import BaseException # Your custom base exception
    try:
        # you can pass whatever special args here that you usually do to BaseException
        raise EasyException('NamedException', parent=BaseException)(...)
    except EasyException('NamedException', parent=BaseException):
        print("Caught the specific exception!") 
    # This exception can still be caught by referencing the BaseException with regular syntax 
    except BaseException:
        print("This would be called if the above exception handler wasn't there")

This can be further simplified by binding the BaseException during application startup using the bind_parent

    from easy_exceptions import EasyException, bind_parent 
    from api.exceptions import BaseException

    bind_parent(BaseException)
    try:
        raise EasyException('NamedException') 
    except BaseException: #Could alse use EasyException('NamedException') to target the named exception only
        print("Exceptions are always of type BaseException now")
tox-pip-version 0.0.7
Select PIP version to use with tox
License: MIT

[![Build Status](https://travis-ci.com/pglass/tox-pip-version.svg?branch=master)](https://travis-ci.com/pglass/tox-pip-version)
![](https://img.shields.io/pypi/v/tox-pip-version.svg)
![](https://img.shields.io/pypi/pyversions/tox-pip-version.svg)

Overview
--------

This is a tox plugin that preinstalls a specific version of pip in each tox
environment.

```bash
pip install tox-pip-version
```

This works around the default behavior of tox/virtualenv that always installs
the latest version pip. It is an improvment over the `VIRTUALENV_NO_DOWNLOAD=1`
option that does not install the latest version, but could result in usage of
an outdated version of pip.

*Recommendation*: Do not pin the pip version long term. You get more stable
repeatable builds, but at the cost of using an outdated (possibly vulnerable)
package. This should be used as a temporary fix for breakages in upstream pip,
or in conjunction with a regular process to update the version pin.

*Note*: This relies on an [unstable tox plugin interface](
https://tox.readthedocs.io/en/latest/plugins.html#tox.hookspecs.tox_testenv_create).
You may experience breakage with new tox versions. If you do, please feel
free to [report the issue](https://github.com/pglass/tox-pip-version/issues/new)
on Github.

### Usage

Install the package and include `pip_version` in your tox.ini

```tox
[testenv]
pip_version = pip==19.0.1
```

Or, set the `TOX_PIP_VERSION` environment variable,

```bash
export TOX_PIP_VERSION=18.1
tox
```

The plugin will install that version of pip into the tox-created virtualenv,
just after tox creates the virtualenv, but before dependencies are installed.

The `pip_version` within tox.ini, if present, is always used over the
environment variable.

If neither `pip_version` or `TOX_PIP_VERSION` is present, the plugin does
nothing.

### Version Sets

Version sets/ranges are supported, enabling installation of a version of pip
matching a set of specifiers. There are two basic formats: a plain version
number, or the package name with optional [PEP440-compatible](
https://www.python.org/dev/peps/pep-0440/#version-specifiers) version
specifiers.

| tox.ini                      | effective pip command        |
| ---------------------------- | ---------------------------- |
| `pip_version = 19.0`         | `pip install -U pip==19.0`   |
| `pip_version = pip==19.0`    | `pip install -U pip==19.0`   |
| `pip_version = pip>=19.0`    | `pip install -U pip>=19.0`   |
| `pip_version = pip!=19,>18`  | `pip install -U pip!=19,>18` |
| `pip_version = pip`          | `pip install -U pip`         |

### Tests

Use `make test` to run the tests, which includes linting and functional tests.

Each of the `tests/*` directories is a "feature" that needs testing. Each
feature sub-directory contains a tox.ini file that sets pip version in a
particular way, and then uses a tox command to check the correct pip version
was installed.