Code Monkey home page Code Monkey logo

multilint's Introduction

multilint

https://github.com/adamchainz/multilint/workflows/CI/badge.svg?branch=master

Unmaintained: I'm no longer maintaining this package because it's for Python 2 compatibility and all other projects I've used it on are now Python 3 only. If you want to continue maintenance please contact me.


Run multiple python linters easily.

Installation and Usage

Install with pip:

python -m pip install multilint

Run with:

multilint

Python 3.5 to 3.8 supported.

How It Works

I like to keep my projects tidy with a standard set of linters. Running them all turned out to be easier with a wrapper script, which I ended up copy-pasting between them all. This project stops me needing to copy/paste, centralizing running all these neat tools.

In order, it will check if these linters are installed, and if so, run them:

  • Black, to autoformat code
  • Flake8, to check code quality
  • Isort, in 'diff' mode to show where imports aren't sorted
  • Modernize, in 'diff' mode to show where python 2/3 compatibility with six is missing

If any of them fail, multilint stops and dies with a non-zero exit code. Otherwise it succeeds!

You need to configure the paths that will be linted (by default, only setup.py is linted). Put a section in your setup.cfg like:

[tool:multilint]
paths = my_package
        tests
        setup.py

You can also pass the paths as arguments to multilint, which will override the settings, like:

multilint path/my_file.py path/folder1

Note: previously multilint supported running setup.py check if you passed a setup.py file. This was removed as the command is deprecated. You should instead use twine check as per the python packaging documentation.

Usage With tox

I normally run my tests with tox. An example tox.ini to use multilint to run your tests on Python 3.5-3.8 and do your linting on Python 3.8 would look like:

[tox]
envlist =
    py{35,36,37,38},
    py38-codestyle

[testenv]
deps = -rrequirements.txt
commands = pytest

[testenv:py38-codestyle]
commands = multilint

Then just put multilint, plus the linters you want it to run (e.g. flake8) in your requirements.txt.

multilint's People

Contributors

adamchainz avatar arthurio avatar rtkaleta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

multilint's Issues

Add pylint support

Those are the linters I see missing from the project, some of those get installed but it doesn't look like we can specify them in the config to ask multilint to run them (haven't actually tried so I may be wrong).

Remove 'setup.py check'

It now gives this deprecation warning:

Running setup.py check
running check
warning: Check: This command has been deprecated. Use `twine check` instead: https://packaging.python.org/guides/making-a-pypi-friendly-readme#validating-restructuredtext-markup

The project's long description is valid RST.

I'm moving my projects to run twine check and after that will look at removing the call to setup.py check here.

tool:multilint section in setup.cfg

Using the 'multilint' name is technically wrong as it's not a setup.py command, we should use the name 'tool:multilint' to avoid clashing with any potential setup.py command we might add in the future.

Support 'python -m multilint'

This can be useful for when one wants to install and run it with a specific python version e.g. python2.7 -m multilint.

setup.py check is not complete on restructured text

Version 1.7.0 of ec2-metadata is broken on display on PyPI because there is a warning in its reStructuredText. The setup.py check test should be looking through the output for warning too.

$ python setup.py check -r -m
running check
warning: check: Duplicate explicit target name: "aws docs".

$ echo $?
0

Run on a specific file only

We'd like to run multilint only on the changed files to test regression only (while we cleanup the rest of the code base). Would it be possible to add positional arguments to the command that would accept file paths (and override settings['paths'])?

multilint path/file1.py path/file2.py

If you are ok with the idea, I'd be happy to submit a PR.

Support Python 2.6

Some projects using multilint e.g. adamchainz/pytest-randomly have to support Python 2.6, it would be good if they could lint on 2.6. This might require disabling some broken linters on those versions.

Do not rely on setup.cfg for configuration

Not every Python project uses setuptools, sometimes all you have is a standalone script. It would be nice if we could still run multilint in those cases.

My suggestion is to have ~/.config/multilint for system-wide config and allow those defaults to be overwritten by a project using a .multilint file at the root of the project (i.e. something like ~/projects/my_project1/.multilint.

That last part will conflict with setup.cfg and tox.ini so there will need to be some rule about precedence.

Crashes when there's no setup.cfg file around

Woops

$ multilint
Traceback (most recent call last):
  File "/Users/adam/.virtualenvs/platform/bin/multilint", line 11, in <module>
    sys.exit(main())
  File "/Users/adam/.virtualenvs/platform/lib/python3.6/site-packages/multilint/__init__.py", line 42, in main
    sys.exit(run(sys.argv[1:]))
  File "/Users/adam/.virtualenvs/platform/lib/python3.6/site-packages/multilint/__init__.py", line 59, in run
    settings = load_settings()
  File "/Users/adam/.virtualenvs/platform/lib/python3.6/site-packages/multilint/__init__.py", line 100, in load_settings
    _update_settings_from_file('setup.cfg', settings)
  File "/Users/adam/.virtualenvs/platform/lib/python3.6/site-packages/multilint/__init__.py", line 119, in _update_settings_from_file
    if config_file and os.path.exists(config_file):
UnboundLocalError: local variable 'config_file' referenced before assignment

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.