Skip to main content

Import order detection

Project description

A script to detect that the import order matches Mozilla WebDev Python guidelines. Usage:

baked.py [filename] [filename..]

Filename can be a glob. Or multiple filenames. For example:

baked.py apps/*.py mkt/*.py

Baked will also accept files being piped to it, for example:

git diff-index HEAD^ --name-only | baked

Baked loads a confg file as JSON. It will look in the following places for the file:

  • the current directory for .baked

  • the users profile directory for .baked

For an example see:

https://gist.github.com/andymckay/5507339

The config file contains:

  • order: the list of orders of import blocks. This allows you to group your imports into categories.

  • fallback: if a category is not found for lib, what should it fall back to, for most this will be local.

  • from_order: a dictionary of sections with a boolean value for each section. If the value is false, then baked will not care that an import came before from. Default is true for each category.

  • modules: a dictionary of categories and a list of modules. This allows baked to put each module in the category.

If you’d like to exclude an import from baked add the comment #NOQA.

Guidelines:

http://mozweb.readthedocs.org/en/latest/coding.html#import-statements

With one exception, we ignore that imports should be ordered CONSTANT, Class, var. Just sort by alpha, case insensitive. That’s easier for everyone to parse.

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

baked-0.1.3.3.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file baked-0.1.3.3.tar.gz.

File metadata

  • Download URL: baked-0.1.3.3.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for baked-0.1.3.3.tar.gz
Algorithm Hash digest
SHA256 e1a6c7e554e7f2eac406eec5153bb89ca24d6ad91bb7d5b1f415ada933738f2a
MD5 608b1d5b70c73dfacf65a93c6ea459e5
BLAKE2b-256 e7bad8c5f75528708965285cb3e2ba445870e52eec2cc5b867e3710ef6058fc9

See more details on using hashes here.

Supported by

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