Giter Site home page Giter Site logo

python-deduckt's Introduction

python-deduckt

Through the powers of deductive interpretation, Deduckt will obtain the precise call graph of your Python programs and the type signatures of all executed functions. Created for the goals of py2nim

How to use

python-deduckt (also launched with python-deduckt/deduckt/main.py) is a drop-in replacement for the python interpreter.

Each traced python execution will update the python-deduckt.json file stored in the current directory. This file stores an annotated AST for each module imported by your program.

python-deduckt full path test.py args

Results

The format is

{
    "<pythonName>": {
        <typeAnnotation>
    }
}

Python name

"<namespaces>.<name>"

name

"<name>" # const
"<name>" # class
"#<name>" # function
"<class>#<name>" # method

Variables

{
    "name": <name>,
    "type": <typeAnnotation>
}

A type annotation can be a class, function description or an atomic type.

{
    "kind": "PyTypeFunction",
    "label": <name>,
    "args": [<variable>],
    "variables": [<variable>],
    "returnType": <typeAnnotation>
}
{
    "kind": "PyTypeObject",
    "label": <name>,
    "fields": [<variable>]
}

Full doc: todo

FAQ

  • Can I generate mypy annotations with it?

It's definitely possible to generate very useful mypy annotations from the recorded data. However that hasn't been our use case, but contributions are welcome

  • Why does it analyze all the events?

In the future we might add an option to trace only a statistically significant part of them. It's not a huge priority for our use case, as we used it for py2nim. A porting task is not something that would be ran often and better type information is more important than speed.

  • How to pronounce deduckt?

Like the first part of "deductive", or like getting rid of the duck types in your backyard.

LICENSE

The MIT License (MIT)

Copyright (c) 2017-2018 Zahary Karadjov, Alexander Ivanov

python-deduckt's People

Contributors

alehander92 avatar jacereda avatar zah avatar nilanjanr avatar

Watchers

 avatar  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.