GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - craigds/decrapify: Some scripts that use pybowler.io for refactoring Python code

This repository was archived by the owner on Jul 17, 2026. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

40 Commits
40 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
debytesify.py
debytesify.py
 
 
fstrings.py
fstrings.py
 
 
obvious_cleanup.py
obvious_cleanup.py
 
 
py3cleanup.py
py3cleanup.py
 
 
pytestify.py
pytestify.py
 
 
requirements.in
requirements.in
 
 
requirements.txt
requirements.txt
 
 
sixify.py
sixify.py
 
 
testfile.py
testfile.py
 
 

Repository files navigation

decrapify

This is a set of scripts which refactor your Python code. They're invocations of Bowler, which is a Facebook incubator project for refactoring Python code using lib2to3.

These scripts are just assorted refactoring steps I've found helpful in my day job as a full time Python developer, that I was unable to find elsewhere.

Please suggest or contribute extra scripts. I will accept any high quality scripts that may be useful, even if they're not useful to me. If you have a cool idea, please open an issue.

fstrings.py {sourcefile.py}

Upgrades source file to use f-strings wherever possible. i.e. converts this

'%s string literal' % myvar

into this:

f'{myvar} string literal'

pytestify.py {sourcefile.py}

Partially converts your xunit-style tests to pytest ones. Doesn't get you all the way there, but reduces the effort required to manually finish the job.

⚠️ Warning

This repo exists primarily as a learning exercise in concrete syntax trees. You should exercise care if trying to using these scripts on code that is dear to you.

Requirements

  • Python 3.6+
  • The other stuff in requirements.txt

Future ideas?

Some ideas I had which I haven't implemented yet:

  • convert super(X, self) to super() (assuming X matches the class def)
  • remove obsolete __future__ import statements (do any of the existing futurize/modernize tools do this? I couldn't find any)
  • re-format/prettify docstrings in some circumstances. (black doesn't touch the contents of docstrings). Specifically I would probably:
    • always use """triple-double-quotes"""
    • always put both start and end quotes on their own line
    • always match the indenation of the quotes to each other
    • always use a raw string if the docstring contains a backslash
    • always indent content to at least the same level as the starting quote marks.

Install

git clone [email protected]:craigds/decrapify.git
virtualenv venv
. venv/bin/activate
pip install -r requirements.txt

About

Some scripts that use pybowler.io for refactoring Python code

Resources

Readme
MIT license
Activity

Stars

13 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.