GithubHelp home page GithubHelp logo

mattwthompson / frappuccino Goto Github PK

View Code? Open in Web Editor NEW

This project forked from carreau/frappuccino

0.0 1.0 0.0 156 KB

Freeze your API

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

frappuccino's Introduction

Frappucino

Freeze your API.

Frappucino allows you during development to make sure you haven't broken API. By first taking an imprint of your API at one point in time and then compare it to the current project state. The goal is to warn you when incompatible changes have been introduces, and list theses.

You could integrate it in you CI to make sure you don't inadvertently break things.

Example:

# old function
def read(name, *, options=None):
    with open(name, 'rb') as f:
        return process(data)

# new function
def read(name_or_buffer, *, options=None):
    if isinstance(name, str):
        with open(name, 'rb') as f:
            data = f.read()
    else:
        data = name_or_buffer.read()
    return process(data)

There is a subtle breakage of API in the above, as you may not remember positional parameters can be use a keyword arguments. That is to say one of your customer may use:

read(name='dump.csv')

Hence changing the name of the positional parameter from name to name_or_buffer is a change of API. There are a number of details like this one where you may end up breaking API without realizing. It's hard to keep track of this when working on dev branches, unit test may not catch all of that. Frappuccino is there to help.

Example:

$ source activate astropy==3.2
$ frappuccino astropy astropy.timeseries --save    astropy.json

$ source activate astropy=master
$ frappuccino astropy astropy.timeseries --compare astropy.json

The following signatures differ between versions:

      - astropy.time.core.TimeDelta.to(self, *args, **kwargs)
      + astropy.time.core.TimeDelta.to(self, unit, equivalencies='[]')

      - astropy.table.table.Table.add_column(self, col, index='None', name='None', rename_duplicate='False', copy='True')
      + astropy.table.table.Table.add_column(self, col, index='None', name='None', rename_duplicate='False', copy='True', default_name='None')

      - astropy.table.table.Table.replace_column(self, name, col)
      + astropy.table.table.Table.replace_column(self, name, col, copy='True')

Other example

cp frappuccino/tests/old.py frappuccino/t.py ; frappuccino frappuccino.t --save t.json; sleep 2;  cp frappuccino/tests/new.py frappuccino/t.py; frappuccino frappuccino.t --compare t.json

frappuccino's People

Contributors

carreau avatar danielballan avatar

Watchers

 avatar

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.