GithubHelp home page GithubHelp logo

thatch / bowler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebookincubator/bowler

0.0 2.0 0.0 985 KB

Safe code refactoring for modern Python.

Home Page: https://pybowler.io

License: MIT License

Python 88.91% Makefile 0.59% JavaScript 9.74% CSS 0.40% Shell 0.36%

bowler's Introduction

Bowler

Safe code refactoring for modern Python projects.

build status code coverage version changelog license code style

Current Development Status

Bowler 0.x is based on fissix (a fork of lib2to3) which was never intended to be a stable api. We've pretty much reached the limit of being able to add new language features, so while we can support 3.8's walrus, that's basically the last it's going to get.

See discussion for f(**not x) for one example -- a proper fix for things like this would mean invalidating all current patterns since there's no way to match against a specific revision of the grammar.

If you need to do codemods today, we recommend looking at LibCST codemods which are a bit more verbose, but work well on modern python grammars. We have contributed support for Python 3.0-3.3 grammars and have a draft PR going even further back to 2.3.

The longer term plan for Bowler is to build Bowler 2.x on top of libcst's parser, while still supporting a very simple fluent api. That's unlikely to materialize in a final release during 2021.

Overview

Bowler is a refactoring tool for manipulating Python at the syntax tree level. It enables safe, large scale code modifications while guaranteeing that the resulting code compiles and runs. It provides both a simple command line interface and a fluent API in Python for generating complex code modifications in code.

Bowler uses a "fluent" Query API to build refactoring scripts through a series of selectors, filters, and modifiers. Many simple modifications are already possible using the existing API, but you can also provide custom selectors, filters, and modifiers as needed to build more complex or custom refactorings. See the Query Reference for more details.

Using the query API to rename a single function, and generate an interactive diff from the results, would look something like this:

query = (
    Query(<paths to modify>)
    .select_function("old_name")
    .rename("new_name")
    .diff(interactive=True)
)

For more details or documentation, check out https://pybowler.io

Installing Bowler

Bowler supports modifications to code from any version of Python 2 or 3, but it requires Python 3.6 or higher to run. Bowler can be easily installed using most common Python packaging tools. We recommend installing the latest stable release from PyPI with pip:

pip install bowler

You can also install a development version from source by checking out the Git repo:

git clone https://github.com/facebookincubator/bowler
cd bowler
python setup.py install

License

Bowler is MIT licensed, as found in the LICENSE file.

bowler's People

Contributors

ajberchek avatar ambv avatar amyreese avatar anentropic avatar bmihelac avatar bugok avatar cdelahousse avatar gdevanla avatar lisroach avatar lorencarvalho avatar ltalirz avatar mariatta avatar marionlb avatar mohi7solanki avatar nataliejameson avatar nicoddemus avatar pengwk avatar rouge8 avatar sadielbartholomew avatar samuelmarks avatar seriallazer avatar syrusakbary avatar thatch avatar veniversum 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.