Skip to main content

A component based framework for designing automated code modification

Project description

Overview

Full documentation available here

Installing

⚠ WARNING: AutoTransform requires Python 3.10

  • Latest Release pip install AutoTransform
  • Bleeding Edge pip install git+git://github.com/nathro/AutoTransform.git
    • Windows users may need to replace git:// with https://
    • If you do not have git use: pip install https://github.com/nathro/AutoTransform/archive/master.zip

After installing via pip, AutoTransform can be initialized using autotransform init. If called within a git repo, this script will also initialize the repo to use AutoTransform. For a simple setup experience, run autotransform init --simple --github or autotransform init --simple --no-github

Summary

AutoTransform is an opensource framework for large-scale code modification. It enables a schema-based system of defining codemods that can then be run using AutoTransform, with options for automatic scheduling as well as change management. AutoTransform leverages a component-based model that allows adopters to quickly and easily get whatever behavior they need through the creation of new, custom components. Additionally, custom components can readily be added to the component library of AutoTransform to be shared more widely with others using the framework.

Goal

The goal of AutoTransform is to make codebase maintenance simple, easy, and automatic. By providing a clear structure for definition, all types of modifications can be automated. Some examples include:

  • Library upgrades
  • API changes
  • Performance improvements
  • Lint or style fixes
  • Dead code
  • One-off refactors
  • Any other programmatically definable modification

Philosophies

Component Based

AutoTransform heavily uses a component based model for functionality. This allows easy customization through the creation of new plug-and-play components. Core logic is about funneling information between components, while the components themselves contain business logic. While AutoTransform provides an ever-growing library of components for ease of adoption, bespoke components will always be needed for some use cases.

Language Agnostic

AutoTransform, though written in Python, is a language agnostic framework. Our component model allows AutoTransform to treat each component as a black-box that can leverage whatever tooling or language makes sense for the goal of the component. This is most heavily needed for the components which actually make code changes where leveraging tools for Abstract(or Concrete) Syntax Trees(AST/CST) is often done in the language being modified.

Minimal Developer Involvement

Managing large scale changes can be extremely time consuming, AutoTransform puts automation first with the goal of automating as much of the process as possible. Developer time is incredibly valuable and should be saved for things that actually require it. If a computer can do it, a computer should do it.

Example - Typing

As an example of how AutoTransform might be used, let’s go through the case of typing a legacy codebase. This is a notoriously difficult and time consuming process.

Static Inference

A codemod can be written that statically infers types from the types around whatever needs types. Hooking this up to scheduled runs would mean that as people type your code, other types can later be inferred. Additionally, as the codemod types code, that can reveal further types that can be statically inferred. This would allow typing to slowly build up over time automatically as the codemod runs and developers introduce more types themselves, significantly speeding up the process of typing a legacy codebase.

Run Time Logging

In addition to static typing, a codemod could instrument untyped functions or other code to log types at run time. These logs could then be fed into the codemod to add types to code that can’t be inferred but can be determined at run time. This codemod could additionally be written to only instrument a small part of the codebase at a given time, preventing excessive resource utilization.

The Whole Versus the Sum of the Parts

Each codemod that can change code can benefit from all other codemods. As run time logging adds types, static inference can make better changes. Dead code removal can clean up untyped code. The layered passes, and building on top of the changes of each codemod, can produce significantly greater wins.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

AutoTransform-0.2.2a4.tar.gz (79.1 kB view details)

Uploaded Source

Built Distribution

AutoTransform-0.2.2a4-py3-none-any.whl (156.5 kB view details)

Uploaded Python 3

File details

Details for the file AutoTransform-0.2.2a4.tar.gz.

File metadata

  • Download URL: AutoTransform-0.2.2a4.tar.gz
  • Upload date:
  • Size: 79.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for AutoTransform-0.2.2a4.tar.gz
Algorithm Hash digest
SHA256 7c64ddd656d75c5fd2e6626cc58cd337dc2bf0c4ece19c3d873e1b37f71a6147
MD5 a178749e6764b9bb43deff050283369e
BLAKE2b-256 1645b9e58fbdcbdedee40a4eb82f19735ce2904d7b86ca442275f52c48cd2358

See more details on using hashes here.

File details

Details for the file AutoTransform-0.2.2a4-py3-none-any.whl.

File metadata

File hashes

Hashes for AutoTransform-0.2.2a4-py3-none-any.whl
Algorithm Hash digest
SHA256 ec669c399a964a7c0ab1d5ad98bee20c1e8c101536e129afa4cbccfa969653ed
MD5 4e0b75a11b4a62ffc81ea8f1ecb6b710
BLAKE2b-256 35490bcc3bfef78931d825e5e62b78bd3b94803596c3f9db54bfcbb913943cd8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page