A lint framework that writes better Python code for you.
Fixit is a lint framework that complements Flake8. It’s based on LibCST which makes it possible to provide auto-fixes. Lint rules are made easy to build through pattern matching, a test toolkit, and utility helpers (e.g. scope analysis) for non-trivial boilerplate. It is optimized for efficiency, easy to customize and comes with many builtin lint rules.
To install Fixit:
pip install fixit
Fixit provides CLI commands. To run built-in Fixit rules on existing code to get code quality suggestions:
python -m fixit.cli.run_rules
To apply autofix on existing code:
python -m fixit.cli.apply_fix
You can learn more about how to configure Fixit, build a lint rule, test a lint rule from our tutorials. Try it out with our notebook examples.
Start by setting up and activating a virtualenv:
git clone [email protected]:Instagram/Fixit.git fixit
cd fixit
python3 -m venv ../fixit-env/ # just an example, put this wherever you want
source ../fixit-env/bin/activate
pip install --upgrade pip # optional, if you have an old system version of pip
pip install -r requirements.txt -r requirements-dev.txt
# If you're done with the virtualenv, you can leave it by running:
deactivate
We use isort and black to format code. To format changes to be conformant, run the following in the root:
tox -e autofix
To run all tests, you'll need to install tox and do the following in the root:
tox -e py37
You can also run individual tests by using unittest and specifying a module like this:
python -m unittest fixit.common.testing.LintRuleTest
See the unittest documentation for more examples of how to run tests.
We use Pyre for type-checking. To verify types for the library, do the following in the root:
pyre --preserve-pythonpath check
To generate documentation, do the following in the root:
tox -e docs
Fixit is MIT licensed, as found in the LICENSE file.