Giter Site home page Giter Site logo

madforhooks's Introduction

Build Status codecov pre-commit.ci status

MadForHooks

Random assorted pre-commit hooks.

Usage

Put this in the repos section of your .pre-commit-config.yaml file:

-   repo: https://github.com/MarcoGorelli/madforhooks
    rev: 0.4.1
    hooks:
    -   id: conda-env-sorter
    -   id: no-print-statements
    -   id: check-execution-order
    -   id: check-test-naming

Or, from the commandline:

pip install madforhooks
python -m madforhooks.check_execution_order file1.ipynb file2.ipynb file3.ipynb

Example of how to run check-test-naming on your test directory:

git ls-files | xargs python -m madforhooks.check_test_naming

Hooks available

conda-env-sorter

Sort the dependencies in your conda environment file(s).

no-print-statements

Raise if print statements are found (unless they have file=).

check-execution-order

Raise if notebook cells were executed out-of-order. Use --strict to ensure strict monotonicity.

check-test-naming

Check that test names start with test. This is useful for finding tests which are meant to be running in CI, but which don't because they are misnamed.

If there are any false positives, you prevent this tool from flagging them by adding a # not a test comment one the line where the function/class is defined.

madforhooks's People

Contributors

j-bowhay avatar leojc avatar marcogorelli avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

raisadz j-bowhay

madforhooks's Issues

Not working when the yml file contains a "pip" term.

Without the "pip" term, it works like a charm!
However, when the yml file contains a "pip" term in it, it raises an error.

Example:

# environment.yml

name: xx
channels:
- defaults
dependencies:
- python=3.8
- pip:
    - transformers

raise an error:
TypeError: '<' not supported between instances of 'CommentedMap' and 'str'

Conda env sorter creates newline on Windows

hi, @MarcoGorelli,
every time I run the pre-commit run --all for PyMC on my Windows machine, the conda env sorter modifies these three environment yamls:

image

Interestingly it doesn't do that for the other environment yamls. The comments in those is different, but more importantly the ones being modified contain a pip: section and the others don't.
Since the pre-commit runs fine in CI I guess it has to do with how line endings are treated in the handling of these pip: sections.

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.