Skip to main content

A tool to help you find and remove unused imports in your python project.

Project description

DEJANKIFY -- remove the jank from your code

This is a tool that helps you maintain your python environment by removing unnecessary dependencies. By default, it will remove all packages that are not explicitly imported in your code. It will also remove any import statements that are for packages that are not referenced in your code. It also creates a requirements.txt file that contains all the packages that are explicitly imported in your code and are not part of the standard library and are pip installable.

This is meant to enhance workflows that are using virtual environments and pip to manage dependencies.

Dejankify works best with pyenv, virtualenv, black, isort, and pylint.

Usage: dejankify [options]

To install run:

pip install dejankify

A sample script before dejankify:

import os
import sys
import re
import json
import requests
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

from sklearn import linear_model
from sklearn.metrics import mean_squared_error, r2_score

name = input("What is your name? ")
first, last = re.match(r"(\w+)\s(\w+)", name).groups()
print(f"Hello {first} {last}!")

The above script would imply the following external dependencies:

  • numpy
  • pandas
  • matplotlib
  • sklearn

Before running dejankify, you would need to install the above packages in your virtual environment and when your code runs it would import the above packages, which would be unnecessary if you are not using them and would slow down your code in addition to increasing the size of your virtual environment.

Now, let's run dejankify:

dejankify

After running dejankify, the script would look like this:

import re

name = input("What is your name? ")
first, last = re.match(r"(\w+)\s(\w+)", name).groups()
print(f"Hello {first} {last}!")

The above script would have no external dependencies and would run faster.

Dejankify will also create several files after it runs that you may delete or version control:

  • requirements.txt - contains all the packages that are explicitly imported in your code and are not part of the standard library and are pip installable.
  • temp_requirements.txt - Your original requirements.txt file will be renamed to this file.
  • invalid_requirements.json - contains a list of packages that are explicitly imported in your code but are not pip installable.
  • valid_requirements.json - contains a list of packages that are explicitly imported in your code and are pip installable.
  • builtins.json - contains a list of all the built-in modules in your version of python.

Project details


Download files

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

Source Distribution

dejankify-0.1.1.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dejankify-0.1.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file dejankify-0.1.1.tar.gz.

File metadata

  • Download URL: dejankify-0.1.1.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for dejankify-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fe3bc69fcd7b782fd2988d3282607c91a7e3039bb6d4c033d5d791c755e8c2fb
MD5 f75c1d2cec241c064d9526448fd091a8
BLAKE2b-256 9de8c41ed2f1557802369d05dce44024c945411caadaa8af9b46fb9e5013d8ba

See more details on using hashes here.

File details

Details for the file dejankify-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dejankify-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for dejankify-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 61e53985b3ad0d0b36567aa7128e3c49d0584cf3b3cd31c68c28eaed3bd27e79
MD5 a780a374167389e63a5770633f0d5b83
BLAKE2b-256 2be0fe5eb197137e22ae583ebe374945e81d27c906af7e441d55ff799c82e60e

See more details on using hashes here.

Supported by

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