Coder Social home page Coder Social logo

jparise / flake8-tidy-imports Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adamchainz/flake8-tidy-imports

0.0 3.0 0.0 21 KB

:eyeglasses: A flake8 plugin that helps you write tidier imports.

License: ISC License

Makefile 7.60% Python 92.40%

flake8-tidy-imports's Introduction

Flake8 Tidy Imports

A flake8 plugin that helps you write tidier imports.

  • Free software: ISC license

Installation

Install from pip with:

pip install flake8-tidy-imports

It will then automatically be run as part of flake8; you can check it has been picked up with:

$ flake8 --version
2.4.1 (pep8: 1.7.0, pyflakes: 0.8.1, flake8-tidy-imports: 1.0.0, mccabe: 0.3.1) CPython 2.7.11 on Darwin

Options

banned-modules

An equals-delimited map of modules to messages to include about them, in rule I201 (see below). Whilst it can be passed on the commandline, it's much easier to configure it in your config file, such as setup.cfg - for example:

[flake8]
banned-modules = mock = Use unittest.mock!
                 urlparse = Use six.moves.urllib.parse!

Rules

Currently this plugin has two rules.

I200: Unnecessary import alias

Complains about unnecessary import aliasing of three forms:

  • import foo as foo -> import foo
  • import foo.bar as bar -> from foo import bar
  • from foo import bar as bar -> from foo import bar

The message includes the suggested rewrite (which may not be correct at current), for example:

$ flake8 file.py
file.py:1:1: I200 Unnecessary import alias - rewrite as 'from foo import bar'.

I201: Banned module 'foo' imported

Complains about importing of banned modules. This might be useful when refactoring code, for example when moving from Python 2 to 3. By default there are no modules banned - you should configure them with banned-modules as described above in 'Options'.

The message includes a user-defined part that comes from the configuration. For example:

$ flake8 file.py
file.py:1:1: I201 Banned module 'mock' imported - Use unittest.mock instead.

flake8-tidy-imports's People

Contributors

adamchainz avatar

Watchers

Jon Parise avatar James Cloos 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.