Skip to main content

A type checking and adapting library

Project description

Anticipate

Build Status

Expect the unexpected, but get what you want.

@anticipate(int)
def get_int():
  return '1'

assert get_int() == 1

@anticipate(str)
def get_str():
  return 22

assert get_str() == '22'

@anticipate([str])
def get_strs(*args):
  return args

assert list(get_strs(1, 2, 3)) == ['1', '2', '3']

Works much better with your own objects or with SpringField

Changelog

0.9.0

  • Dropped support for Python 2.6, added support for Python 3.7.
  • Cleaned up code formatting

Bug Fixes

  • Fixed issue that prevented use of an adaptable object (has an adapt method) as an anticipated list of type.

0.8.0

  • Change so that anticipating an iterable using [type] will always return a list instead of generator
  • Added anticipate_input_factory to make it easier to implement input handlers that need to inject values or handle input errors differently
  • Made it so you can use any object that implements adapt as an anticipate type so you can use SpringField fields as input types
  • Improved error messages
  • Split anticipate input and output handling into separate functions to make it easier to intercept input or output handling
  • Check that the params being anticipated exist in the function signature

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
anticipate-0.9.1-py3-none-any.whl (7.9 kB) Copy SHA256 hash SHA256 Wheel py3
anticipate-0.9.1.tar.gz (10.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page