Skip to content

Fixit is a Python Lint Framework based on LibCST. It comes with useful default lint rules for coding convention, performance and security issues. It makes custom lint rule easy to build, test and configure. It empowers lint rule to provide autofix to fix the issues for developers. It also provide tools to run autofix across codebase to fix exist…

master
Go to file
Code

Latest commit

…sertTrue() (#135)

* Add a rule to catch some incorrect uses of assertTrue()

assertTrue() calls with 2 arguments when the intention is clearly to
compare the values are surprisingly common. This is valid syntax, but
completely incorrect semantics as no comparison is done and the second
argument is used as the assertion failure message.

See some examples:
https://grep.app/search?q=self%5C.assertTrue%5C%28.%2B%2C%5Cs%2A%28%5B%2B-%5D%3F%280%5Bxb%5D%29%3F%5Cd%2B%28%5C.%5Cd%2B%29%3F%7CTrue%7C%5C%5B.%2A%5C%5D%29%5C%29%24&regexp=true&filter[lang][0]=Python

Some incorrect cases are not caught by this rule because there's no way to always reliably determine the role of the second argument. One example is:
https://github.com/vibora-io/vibora/blob/master/tests/schemas/schemas.py#L18

* Fix a typing error
f27c94d

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.rst

Fixit

Documentation codecov-badge PYPI PYPI Download

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.

Getting Started

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.

Further Reading

Development

Start by setting up and activating a virtualenv:

git clone git@github.com: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

License

Fixit is MIT licensed, as found in the LICENSE file.

Privacy Policy and Terms of Use

About

Fixit is a Python Lint Framework based on LibCST. It comes with useful default lint rules for coding convention, performance and security issues. It makes custom lint rule easy to build, test and configure. It empowers lint rule to provide autofix to fix the issues for developers. It also provide tools to run autofix across codebase to fix exist…

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.