CINXE.COM
Flake8: Your Tool For Style Guide Enforcement — flake8 7.1.0 documentation
<!DOCTYPE html> <html class="writer-html5" lang="en" data-content_root="./"> <head> <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Flake8: Your Tool For Style Guide Enforcement — flake8 7.1.0 documentation</title> <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" /> <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" /> <!--[if lt IE 9]> <script src="_static/js/html5shiv.min.js"></script> <![endif]--> <script src="_static/jquery.js?v=5d32c60e"></script> <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script> <script src="_static/documentation_options.js?v=9e30f436"></script> <script src="_static/doctools.js?v=9a2dae69"></script> <script src="_static/sphinx_highlight.js?v=dc90522c"></script> <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Frequently Asked Questions" href="faq.html" /> <!-- RTD Extra Head --> <script type="application/json" id="READTHEDOCS_DATA">{"ad_free": false, "api_host": "https://readthedocs.org", "builder": "sphinx", "canonical_url": null, "docroot": "/docs/source/", "features": {"docsearch_disabled": false}, "global_analytics_code": "UA-17997319-1", "language": "en", "page": "index", "programming_language": "py", "project": "flake8", "proxied_api_host": "/_", "source_suffix": ".rst", "subprojects": {}, "theme": "sphinx_rtd_theme", "user_analytics_code": "UA-57263828-2", "version": "latest"}</script> <!-- Using this variable directly instead of using `JSON.parse` is deprecated. The READTHEDOCS_DATA global variable will be removed in the future. --> <script type="text/javascript"> READTHEDOCS_DATA = JSON.parse(document.getElementById('READTHEDOCS_DATA').innerHTML); </script> <!-- end RTD <extrahead> --> <script async type="text/javascript" src="/_/static/javascript/readthedocs-addons.js"></script><meta name="readthedocs-project-slug" content="flake8" /><meta name="readthedocs-version-slug" content="latest" /><meta name="readthedocs-resolver-filename" content="/" /><meta name="readthedocs-http-status" content="200" /></head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > <a href="#" class="icon icon-home"> flake8 </a> <div class="version"> latest </div> <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <ul> <li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary of Terms Used in Flake8 Documentation</a></li> </ul> <ul> <li class="toctree-l1"><a class="reference internal" href="user/index.html">Using Flake8</a></li> </ul> <ul> <li class="toctree-l1"><a class="reference internal" href="plugin-development/index.html">Writing Plugins for Flake8</a></li> </ul> <ul> <li class="toctree-l1"><a class="reference internal" href="internal/index.html">Exploring Flake8’s Internals</a></li> </ul> <ul> <li class="toctree-l1"><a class="reference internal" href="release-notes/index.html">Release Notes and History</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="#">flake8</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> <li><a href="#" class="icon icon-home" aria-label="Home"></a></li> <li class="breadcrumb-item active">Flake8: Your Tool For Style Guide Enforcement</li> <li class="wy-breadcrumbs-aside"> <a href="https://github.com/pycqa/flake8/blob/main/docs/source/index.rst" class="fa fa-github"> Edit on GitHub</a> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <section id="flake8-your-tool-for-style-guide-enforcement"> <h1>Flake8: Your Tool For Style Guide Enforcement<a class="headerlink" href="#flake8-your-tool-for-style-guide-enforcement" title="Link to this heading"></a></h1> <section id="quickstart"> <h2>Quickstart<a class="headerlink" href="#quickstart" title="Link to this heading"></a></h2> <section id="installation"> <span id="installation-guide"></span><h3>Installation<a class="headerlink" href="#installation" title="Link to this heading"></a></h3> <p>To install <strong class="program">Flake8</strong>, open an interactive shell and run:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span><span class="o"><</span><span class="n">version</span><span class="o">></span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">flake8</span> </pre></div> </div> <p>If you want <strong class="program">Flake8</strong> to be installed for your default Python installation, you can instead use:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">flake8</span> </pre></div> </div> <div class="admonition note"> <p class="admonition-title">Note</p> <p>It is <strong>very</strong> important to install <strong class="program">Flake8</strong> on the <em>correct</em> version of Python for your needs. If you want <strong class="program">Flake8</strong> to properly parse new language features in Python 3.5 (for example), you need it to be installed on 3.5 for <strong class="program">Flake8</strong> to understand those features. In many ways, Flake8 is tied to the version of Python on which it runs.</p> </div> </section> <section id="using-flake8"> <h3>Using Flake8<a class="headerlink" href="#using-flake8" title="Link to this heading"></a></h3> <p>To start using <strong class="program">Flake8</strong>, open an interactive shell and run:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">flake8</span> <span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">code</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">check</span><span class="o">.</span><span class="n">py</span> <span class="c1"># or</span> <span class="n">flake8</span> <span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">code</span><span class="o">/</span> </pre></div> </div> <div class="admonition note"> <p class="admonition-title">Note</p> <p>If you have installed <strong class="program">Flake8</strong> on a particular version of Python (or on several versions), it may be best to instead run <code class="docutils literal notranslate"><span class="pre">python<version></span> <span class="pre">-m</span> <span class="pre">flake8</span></code>.</p> </div> <p>If you only want to see the instances of a specific warning or error, you can <em>select</em> that error like so:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">flake8</span> <span class="o">--</span><span class="n">select</span> <span class="n">E123</span><span class="p">,</span><span class="n">W503</span> <span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">code</span><span class="o">/</span> </pre></div> </div> <p>Alternatively, if you want to add a specific warning or error to <em>ignore</em>:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">flake8</span> <span class="o">--</span><span class="n">extend</span><span class="o">-</span><span class="n">ignore</span> <span class="n">E203</span><span class="p">,</span><span class="n">W234</span> <span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">code</span><span class="o">/</span> </pre></div> </div> <p>Please read our user guide for more information about how to use and configure <strong class="program">Flake8</strong>.</p> </section> </section> <section id="faq-and-glossary"> <h2>FAQ and Glossary<a class="headerlink" href="#faq-and-glossary" title="Link to this heading"></a></h2> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a><ul> <li class="toctree-l2"><a class="reference internal" href="faq.html#when-is-flake8-released">When is Flake8 released?</a></li> <li class="toctree-l2"><a class="reference internal" href="faq.html#how-can-i-help-flake8-release-faster">How can I help Flake8 release faster?</a></li> <li class="toctree-l2"><a class="reference internal" href="faq.html#what-is-the-next-version-of-flake8">What is the next version of Flake8?</a></li> <li class="toctree-l2"><a class="reference internal" href="faq.html#why-does-flake8-use-ranges-for-its-dependencies">Why does Flake8 use ranges for its dependencies?</a></li> <li class="toctree-l2"><a class="reference internal" href="faq.html#should-i-file-an-issue-when-a-new-version-of-a-dependency-is-available">Should I file an issue when a new version of a dependency is available?</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary of Terms Used in Flake8 Documentation</a></li> </ul> </div> </section> <section id="user-guide"> <h2>User Guide<a class="headerlink" href="#user-guide" title="Link to this heading"></a></h2> <p>All users of <strong class="program">Flake8</strong> should read this portion of the documentation. This provides examples and documentation around <strong class="program">Flake8</strong>’s assortment of options and how to specify them on the command-line or in configuration files.</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="user/index.html">Using Flake8</a><ul> <li class="toctree-l2"><a class="reference internal" href="user/invocation.html">Invoking Flake8</a></li> <li class="toctree-l2"><a class="reference internal" href="user/configuration.html">Configuring Flake8</a></li> <li class="toctree-l2"><a class="reference internal" href="user/options.html">Full Listing of Options and Their Descriptions</a></li> <li class="toctree-l2"><a class="reference internal" href="user/error-codes.html">Error / Violation Codes</a></li> <li class="toctree-l2"><a class="reference internal" href="user/violations.html">Selecting and Ignoring Violations</a></li> <li class="toctree-l2"><a class="reference internal" href="user/using-plugins.html">Using Plugins For Fun and Profit</a></li> <li class="toctree-l2"><a class="reference internal" href="user/using-hooks.html">Using Version Control Hooks</a></li> <li class="toctree-l2"><a class="reference internal" href="user/python-api.html">Public Python API</a></li> </ul> </li> </ul> </div> </section> <section id="plugin-developer-guide"> <h2>Plugin Developer Guide<a class="headerlink" href="#plugin-developer-guide" title="Link to this heading"></a></h2> <p>If you’re maintaining a plugin for <strong class="program">Flake8</strong> or creating a new one, you should read this section of the documentation. It explains how you can write your plugins and distribute them to others.</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="plugin-development/index.html">Writing Plugins for Flake8</a><ul> <li class="toctree-l2"><a class="reference internal" href="plugin-development/index.html#getting-started">Getting Started</a></li> <li class="toctree-l2"><a class="reference internal" href="plugin-development/index.html#video-tutorial">Video Tutorial</a></li> <li class="toctree-l2"><a class="reference internal" href="plugin-development/index.html#detailed-plugin-development-documentation">Detailed Plugin Development Documentation</a></li> </ul> </li> </ul> </div> </section> <section id="contributor-guide"> <h2>Contributor Guide<a class="headerlink" href="#contributor-guide" title="Link to this heading"></a></h2> <p>If you are reading <strong class="program">Flake8</strong>’s source code for fun or looking to contribute, you should read this portion of the documentation. This is a mix of documenting the internal-only interfaces <strong class="program">Flake8</strong> and documenting reasoning for Flake8’s design.</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="internal/index.html">Exploring Flake8’s Internals</a><ul> <li class="toctree-l2"><a class="reference internal" href="internal/contributing.html">Contributing to Flake8</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/writing-documentation.html">Writing Documentation for Flake8</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/writing-code.html">Writing Code for Flake8</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/releases.html">Releasing Flake8</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/start-to-finish.html">What Happens When You Run Flake8</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/checker.html">How Checks are Run</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/cli.html">Command Line Interface</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/formatters.html">Built-in Formatters</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/option_handling.html">Option and Configuration Handling</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/plugin_handling.html">Plugin Handling</a></li> <li class="toctree-l2"><a class="reference internal" href="internal/utils.html">Utility Functions</a></li> </ul> </li> </ul> </div> </section> <section id="release-notes-and-history"> <h2>Release Notes and History<a class="headerlink" href="#release-notes-and-history" title="Link to this heading"></a></h2> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="release-notes/index.html">Release Notes and History</a><ul> <li class="toctree-l2"><a class="reference internal" href="release-notes/index.html#x-release-series">7.x Release Series</a></li> <li class="toctree-l2"><a class="reference internal" href="release-notes/index.html#id1">6.x Release Series</a></li> <li class="toctree-l2"><a class="reference internal" href="release-notes/index.html#id2">5.x Release Series</a></li> <li class="toctree-l2"><a class="reference internal" href="release-notes/index.html#id3">4.x Release Series</a></li> <li class="toctree-l2"><a class="reference internal" href="release-notes/index.html#id4">3.x Release Series</a></li> <li class="toctree-l2"><a class="reference internal" href="release-notes/index.html#id5">2.x Release Series</a></li> <li class="toctree-l2"><a class="reference internal" href="release-notes/index.html#id6">1.x Release Series</a></li> <li class="toctree-l2"><a class="reference internal" href="release-notes/index.html#id7">0.x Release Series</a></li> </ul> </li> </ul> </div> </section> <section id="general-indices"> <h2>General Indices<a class="headerlink" href="#general-indices" title="Link to this heading"></a></h2> <ul class="simple"> <li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li> <li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Index of Documented Public Modules</span></a></p></li> <li><p><a class="reference internal" href="glossary.html#glossary"><span class="std std-ref">Glossary of terms</span></a></p></li> </ul> </section> </section> </div> </div> <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> <a href="faq.html" class="btn btn-neutral float-right" title="Frequently Asked Questions" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> <hr/> <div role="contentinfo"> <p>© Copyright 2016, Ian Stapleton Cordasco. <span class="commit">Revision <code>65a38c42</code>. </span></p> </div> Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> </body> </html>