guilatrova / tryceratops

A linter to prevent exception handling antipatterns in Python (limited only for those who like dinosaurs).
MIT License
432 stars 26 forks source link

feat: add plugin for flake8 #9

Closed guilatrova closed 3 years ago

guilatrova commented 3 years ago

Steps:

Results

Running flake8 --help:

Installed plugins: mccabe: 0.6.1, pycodestyle: 2.7.0, pyflakes: 2.3.1, tryceratops: 0.2.3

Running flake8 on file:

❯ flake8 src/tests/samples/violations/call_raise_vanilla.py
src/tests/samples/violations/call_raise_vanilla.py:13:9: TC003 Avoid specifying long messages outside the exception class
src/tests/samples/violations/call_raise_vanilla.py:13:9: TC002 Create your own exception
src/tests/samples/violations/call_raise_vanilla.py:18:9: F841 local variable 'a' is assigned to but never used
src/tests/samples/violations/call_raise_vanilla.py:21:9: TC201 Simply use 'raise' without specifying exception object again

Running flake8 --select

❯ flake8 --select TC src/tests/samples/violations/call_raise_vanilla.py
src/tests/samples/violations/call_raise_vanilla.py:13:9: TC002 Create your own exception
src/tests/samples/violations/call_raise_vanilla.py:13:9: TC003 Avoid specifying long messages outside the exception class
src/tests/samples/violations/call_raise_vanilla.py:21:9: TC201 Simply use 'raise' without specifying exception object again
guilatrova commented 3 years ago

Useful resource: https://flake8.pycqa.org/en/latest/internal/checker.html