Giter Club home page Giter Club logo

anticipate's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.