Giter Club home page Giter Club logo

pre-commit-docker-flake8's Introduction

pre-commit-docker-flake8

What is this?

This is a proof-of-concept of providing a pre-commit hook for flake8 via docker. It is suggested to instead use flake8 as provided by pre-commit-hooks as you'll have slightly better performance and more control over the python executable.

How does this work?

pre-commit by convention mounts the user's code at /src inside the container. The executable is fed relative path filename arguments. The hook may make changes to the files as the source is mounted read-only and the executables are run as the user

A few key lines in the Dockerfile make this work:

RUN virtualenv /venv -ppython3 && /venv/bin/pip install flake8
ENV PATH=/venv/bin:$PATH

This creates a virtual environment inside the docker image and puts the virtualenv on the PATH so executables (such as flake8) can be run.

Lastly, the metadata in hooks.yaml hooks this up:

    entry: flake8
    language: docker

Here flake8 is the executable inside the container and we tell pre-commit that the language is docker.

How would I use this repository with pre-commit?

Well, you probably wouldn't (and the hook has been labeled as such) but if you really wanted to you could add this to your .pre-commit-config.yaml:

-   repo: git://github.com/pre-commit/pre-commit-docker-flake8
    sha: ''  # Fill this in with a current revision
    hooks:
    -   id: flake8-docker-not-for-production

You'll also need to use at least version 0.10.0 of pre-commit.

pre-commit-docker-flake8's People

Contributors

asottile avatar

Watchers

 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.