Flake8 wrapper to make it nice, legacy-friendly, configurable.

Overview

THE PROJECT IS ARCHIVED

Forks: https://github.com/orsinium/forks


FlakeHell

PyPI version Build Status License: MIT Documentation

It's a Flake8 wrapper to make it cool.

output example

Compatibility

FlakeHell supports all flake8 plugins, formatters, and configs. However, FlakeHell has it's own beautiful way to configure enabled plugins and codes. So, options like --ignore and --select unsupported. You can have flake8 and FlakeHell in one project if you want but enabled plugins should be explicitly specified.

Installation

python3 -m pip install --user flakehell

Usage

First of all, let's create pyproject.toml config:

[tool.flakehell]
# optionally inherit from remote config (or local if you want)
base = "https://raw.githubusercontent.com/life4/flakehell/master/pyproject.toml"
# specify any flake8 options. For example, exclude "example.py":
exclude = ["example.py"]
# make output nice
format = "grouped"
# 80 chars aren't enough in 21 century
max_line_length = 90
# show line of source code in output
show_source = true

# list of plugins and rules for them
[tool.flakehell.plugins]
# include everything in pyflakes except F401
pyflakes = ["+*", "-F401"]
# enable only codes from S100 to S199
flake8-bandit = ["-*", "+S1??"]
# enable everything that starts from `flake8-`
"flake8-*" = ["+*"]
# explicitly disable plugin
flake8-docstrings = ["-*"]

Show plugins that aren't installed yet:

flakehell missed

Show installed plugins, used plugins, specified rules, codes prefixes:

flakehell plugins

plugins command output

Show codes and messages for a specific plugin:

flakehell codes pyflakes

codes command output

Run flake8 against the code:

flakehell lint

This command accepts all the same arguments as Flake8.

Read flakehell.readthedocs.io for more information.

Contributing

Contributions are welcome! A few ideas what you can contribute:

  • Improve documentation.
  • Add more tests.
  • Improve performance.
  • Found a bug? Fix it!
  • Made an article about FlakeHell? Great! Let's add it into the README.md.
  • Don't have time to code? No worries! Just tell your friends and subscribers about the project. More users -> more contributors -> more cool features.

A convenient way to run tests is using DepHell:

curl -L dephell.org/install | python3
dephell venv create --env=pytest
dephell deps install --env=pytest
dephell venv run --env=pytest

Bug-tracker is disabled by-design to shift contributions from words to actions. Please, help us make the project better and don't stalk maintainers in social networks and on the street.

Thank you ❤️

The FlakeHell mascot (Flaky) is created by @illustrator.way and licensed under the CC BY-SA 4.0 license.

Comments
  • Allow flakehell to be installed from the source alone

    Allow flakehell to be installed from the source alone

    See https://flit.readthedocs.io/en/latest/pyproject_toml.html#build-system-section

    This will allow flakehell installable from just the source. E.g. pip install git+git+https://github.com/life4/flakehell

    opened by thejcannon 6
  • Fix --config handling and allow --append-config

    Fix --config handling and allow --append-config

    From my testing, passing --config ./file.toml wasn't being handled correctly. Debugging it, it looks like parse_preliminary_options in flake8 strips out these options, so by the time we get to it in parse_configuration_and_cli they are nowhere to be found in argv.

    opened by thejcannon 4
  • Update message output

    Update message output

    • Adding the pylint symbol (verbal error code) makes disabling certain errors a bit easier.
    • Printing error codes in only one color makes them a bit more readable and from my experience, there is no real need to make the number stand out.

    The pylint issue is more important for me. If you have any objections against the other change, I can revert it. :)

    opened by sscherfke 3
  • Try multiple cache locations

    Try multiple cache locations

    In CI environment, depending on the user and whether it has a home, flakehell would try to create the /.cache directory, and would fail with a PermissionError.

    This commit changes that by making flakehell try to create the cache at different locations: $HOME/.cache/flakehell and ./.flakehell_cache (the chances we can write into the current directory in CI are high).

    A --disable-cache option would be much more robust but seems to be way more complicated to implement.

    Hacktoberfest 
    opened by pawamoy 3
  • Where has the bug tracker gone?

    Where has the bug tracker gone?

    The exclude option is still broken in 0.4.5, I still get a SyntaxError on a file that is in the exclude list.

    I'm also struggling to figure out how this would be used as a git hook.

    opened by Dreamsorcerer 3
  • Fix exception thrown when nonexistent filename, especially `-` is passed

    Fix exception thrown when nonexistent filename, especially `-` is passed

    The error is caused by Snapshot class naively reading in file content to create a md5 digest for the file. This is not possible when - is passed, because a) it is most likely not an existing filename, and b) even if we were to interpret it as stdin, it isn't seekable (outside of using os.lseek when a real file was redirected).

    The fix: when calculating digests for a non-existent file, just invent one from current time and a random value. It will be a new value every time, ensuring no caching between such stdin invocations.

    Fixes #44

    opened by k3rni 3
  • fix flakehell version passed to flake8 application

    fix flakehell version passed to flake8 application

    Currently flakehell is using 2 versions:

    • flakehell.__version__ which is pypi package version
    • flakehell._constants.VERSION which is passed to Flake8Application as version kwarg

    Maybe it's some leftover after refactor or something, but it's quite confusing and imho only one version number should be used for both cases. Please correct me if I am wrong, because maybe I misunderstood something.

    Thanks for maintaining this really useful project!

    opened by skarzi 3
  • Please rename or remove the yesqa sub command

    Please rename or remove the yesqa sub command

    opened by asottile 2
  • Add support for intersection between exceptions

    Add support for intersection between exceptions

    Not sure if the current behavior is by design or not. When some file is matched by two or more exceptions, only one exception is applied and it is not obvious which one (the one with a shorter path actually). So, i suggest to apply all matched exceptions.

    opened by evgeniyz321 2
  • Use FLAKEHELL_CACHE environment variable

    Use FLAKEHELL_CACHE environment variable

    A PermissionError can be raised when trying to create the cache directory. We allow the user to change the cache path with the FLAKEHELL_CACHE environment variable to work around this issue.

    Replaces #101.

    Hacktoberfest 
    opened by pawamoy 2
  • Baseline hashes not use forward-slash on all platforms

    Baseline hashes not use forward-slash on all platforms

    This will allow baseline files to be generated on any platform to be consumed on any platform.

    NOTE: Unfortunately, this will break existing baseline files generated on machines that use back slashes.

    opened by thejcannon 2
  • Fix --config handling and allow --append-config

    Fix --config handling and allow --append-config

    From my testing, passing --config ./file.toml wasn't being handled correctly. Debugging it, it looks like parse_preliminary_options in flake8 strips out these options, so by the time we get to it in parse_configuration_and_cli they are nowhere to be found in argv.

    opened by thejcannon 4
Owner
Life4
Original cool Open Source projects
Life4
MyPy types for WSGI applications

WSGI Types for Python This is an attempt to bring some type safety to WSGI applications using Python's new typing features (TypedDicts, Protocols). It

Blake Williams 2 Aug 18, 2021
PEP-484 typing stubs for SQLAlchemy 1.4 and SQLAlchemy 2.0

SQLAlchemy 2 Stubs These are PEP-484 typing stubs for SQLAlchemy 1.4 and 2.0. They are released concurrently along with a Mypy extension which is desi

SQLAlchemy 139 Dec 30, 2022
Flake8 extension for checking quotes in python

Flake8 Extension to lint for quotes. Major update in 2.0.0 We automatically encourage avoiding escaping quotes as per PEP 8. To disable this, use --no

Zachary Heller 157 Dec 13, 2022
Mylint - My really simple rendition of how a linter works.

mylint My really simple rendition of how a linter works. This original version was written for my AST article. Since then I've added tests and turned

Tushar Sadhwani 2 Dec 29, 2021
The strictest and most opinionated python linter ever!

wemake-python-styleguide Welcome to the strictest and most opinionated python linter ever. wemake-python-styleguide is actually a flake8 plugin with s

wemake.services 2.1k Jan 01, 2023
Naming Convention checker for Python

PEP 8 Naming Conventions Check your code against PEP 8 naming conventions. This module provides a plugin for flake8, the Python code checker. (It repl

Python Code Quality Authority 411 Dec 23, 2022
Rust like Option and Result types in Python

Option Rust-like Option and Result types in Python, slotted and fully typed. An Option type represents an optional value, every Option is either Some

45 Dec 13, 2022
Flake8 extension for enforcing trailing commas in python

Flake8 Extension to enforce better comma placement. Usage If you are using flake8 it's as easy as: pip install flake8-commas Now you can avoid those a

Python Code Quality Authority 127 Sep 03, 2022
Convert relative imports to absolute

absolufy-imports A tool and pre-commit hook to automatically convert relative imports to absolute. Installation $ pip install absolufy-imports Usage a

Marco Gorelli 130 Dec 30, 2022
Python classes with types validation at runtime.

typedclasses Python classes with types validation at runtime. (Experimental & Under Development) Installation You can install this library using Pytho

Izhar Ahmad 8 Feb 06, 2022
Collection of awesome Python types, stubs, plugins, and tools to work with them.

Awesome Python Typing Collection of awesome Python types, stubs, plugins, and tools to work with them. Contents Static type checkers Dynamic type chec

TypedDjango 1.2k Jan 04, 2023
Flake8 plugin for managing type-checking imports & forward references

flake8-type-checking Lets you know which imports to put in type-checking blocks. For the imports you've already defined inside type-checking blocks, i

snok 67 Dec 16, 2022
👻 Phantom types for Python

phantom-types Phantom types for Python will help you make illegal states unrepresentable and avoid shotgun parsing by enabling you to practice "Parse,

Anton Agestam 118 Dec 22, 2022
❄️ A flake8 plugin to help you write better list/set/dict comprehensions.

flake8-comprehensions A flake8 plugin that helps you write better list/set/dict comprehensions. Requirements Python 3.6 to 3.9 supported. Installation

Adam Johnson 398 Dec 23, 2022
A Python Parser

parso - A Python Parser Parso is a Python parser that supports error recovery and round-trip parsing for different Python versions (in multiple Python

Dave Halter 520 Dec 26, 2022
Mypy stubs, i.e., type information, for numpy, pandas and matplotlib

Mypy type stubs for NumPy, pandas, and Matplotlib This is a PEP-561-compliant stub-only package which provides type information for matplotlib, numpy

Predictive Analytics Lab 194 Dec 19, 2022
Backport Python 3.8+ typing utils & add issubtype & more

typing-utils Backport Python3.8+ typing utils & issubtype & more Install API issubtype get_origin get_args get_type_hints Install pip install typi

10 Nov 09, 2022
An extension for flake8 that forbids some imports statements in some modules.

flake8-obey-import-goat An extension for flake8 that forbids some imports statements in some modules. Important: this project is developed using DDD,

Ilya Lebedev 10 Nov 09, 2022
A plugin for Flake8 that provides specializations for type hinting stub files

flake8-pyi A plugin for Flake8 that provides specializations for type hinting stub files, especially interesting for linting typeshed. Functionality A

Łukasz Langa 58 Jan 04, 2023
Unbearably fast O(1) runtime type-checking in pure Python.

Look for the bare necessities, the simple bare necessities. Forget about your worries and your strife. — The Jungle Book.

beartype 1.4k Jan 01, 2023