Registry / testing / flake8-html

flake8-html

JSON →
library0.4.3pypypiunverified

flake8-html is a plugin for the flake8 linter that generates an HTML report of code violations, providing a visual and navigable overview of issues. The current version is 0.4.3. It has an infrequent release cadence, primarily updating to maintain compatibility with new versions of flake8.

pip install flake8-html
INSTALL
IMPORT
SIG · FLAKE8-HTML
F
flake8-html
testingpythonv0.4.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

This quickstart demonstrates how to use `flake8-html` via the `flake8` command-line interface. It creates a temporary Python file with a linter violation, runs `flake8` to generate an HTML report, and then cleans up. The `--format=html` and `--htmldir` arguments are essential for generating the report.

import subprocess import os # Create a dummy Python file with a flake8 violation code_to_lint = """ import os def my_func( arg1, arg2 ): print( os.path.join(arg1, arg2) ) """ with open("test_code.py", "w") as f: f.write(code_to_lint) # Ensure the report directory exists report_dir = "./flake8_html_report" os.makedirs(report_dir, exist_ok=True) # Run flake8 with the html format print(f"Running: flake8 --format=html --htmldir={report_dir} .") try: result = subprocess.run( ["flake8", "--format=html", f"--htmldir={report_dir}", "."], capture_output=True, text=True, check=True ) print("Flake8 HTML report generated successfully.") print(f"Report saved to: {os.path.abspath(report_dir)}/report.html") except subprocess.CalledProcessError as e: print(f"Error running flake8: {e}\n{e.stderr}") except FileNotFoundError: print("Error: 'flake8' command not found. Please ensure flake8 is installed.") finally: # Clean up dummy file if os.path.exists("test_code.py"): os.remove("test_code.py") # Optionally, remove the report directory for a clean run next time # import shutil # if os.path.exists(report_dir): # shutil.rmtree(report_dir)
Debug
Known issues
breakingOlder versions of `flake8-html` (prior to 0.4.3) are incompatible with `flake8` versions 5.0.0 and above.
fix
Upgrade `flake8-html` to version 0.4.3 or newer: `pip install --upgrade flake8-html`.
affects: <0.4.3
gotchaFor `flake8-html` to be discovered and used by `flake8`, it must be installed in the exact same Python environment (e.g., virtual environment) as `flake8` itself.
fix
Ensure both `flake8` and `flake8-html` are installed using the same `pip` command or within the same active virtual environment: `pip install flake8 flake8-html`.
affects: All versions
gotchaFailing to specify the `--htmldir` argument will prevent the HTML report from being saved to a file, potentially causing the output to be printed to the console in an unreadable format or not generated at all.
fix
Always include `--htmldir=<path/to/directory>` in your `flake8` command to specify where the `report.html` file should be saved.
affects: All versions
Errors
Common errors & fixes
Error: unrecognized arguments: --format=html
The `flake8-html` plugin is not installed, or `flake8` cannot find it in the current environment.
fix
Install `flake8-html` in the same Python environment as `flake8`: `pip install flake8-html`.
No 'report.html' file was generated in the expected directory.
The `--htmldir` argument was either omitted or specified incorrectly, preventing `flake8-html` from saving the report to disk.
fix
Ensure you are using `--htmldir=<path/to/report>` to specify the output directory for the HTML report.
The generated HTML report is empty or appears incomplete despite having linter violations.
This often occurs when `flake8-html < 0.4.3` is used with `flake8 >= 5.0.0` due to compatibility issues.
fix
Upgrade `flake8-html` to the latest version to ensure compatibility: `pip install --upgrade flake8-html`.
Upgrade
Version history
0.4.3latest on PyPI · released Dec 6, 2022
Audit
Dependencies
flake8requiredflake8-html is a plugin for flake8 and requires flake8 to be installed and available in the same Python environment to function.
Agent activity
6 hits · last 30 days
node
6
Resources
flake8-html — pip install flake8-html · libregistry