{"id":6635,"library":"flake8-functions","title":"flake8-functions","description":"flake8-functions is a Flake8 extension that checks for issues related to Python functions, such as excessive length, too many arguments, purity, and number of return statements. It provides specific error codes like CFQ001, CFQ002, CFQ003, and CFQ004. The current version is 0.0.8, released on April 10, 2023. This is an actively maintained project with releases as needed to address issues and enhance checks.","status":"active","version":"0.0.8","language":"en","source_language":"en","source_url":"https://github.com/best-doctor/flake8-functions","tags":["flake8","linter","code-quality","functions","pep8"],"install":[{"cmd":"pip install flake8 flake8-functions","lang":"bash","label":"Install library"}],"dependencies":[{"reason":"This library is a plugin for Flake8 and requires Flake8 to function.","package":"flake8","optional":false},{"reason":"Requires Python 3.7 or newer. Although PyPI lists 3.6-3.10, the GitHub README specifies 3.7+.","package":"Python","optional":false}],"imports":[],"quickstart":{"code":"import os\n\ndef some_long_function(first_parameter, second_parameter, third_parameter):\n    # This function is intentionally long to trigger CFQ001\n    result = first_parameter + second_parameter\n    result = result * third_parameter\n    result = result / (first_parameter + 1)\n    result = result % second_parameter\n    result = result ** 2\n    result = result + first_parameter + second_parameter + third_parameter\n    result = result * 5 - 10\n    result = result + 100 / (second_parameter - 1)\n    result = result - (third_parameter * first_parameter)\n    result = result * (first_parameter + second_parameter + third_parameter)\n    return first_parameter\n\ndef short_function():\n    return 1\n\n# Save this code to a file named 'example.py'\n# Then run: flake8 --max-function-length=10 example.py","lang":"python","description":"Install flake8 and flake8-functions, then run flake8 on a Python file. flake8-functions checks are automatically integrated. The example shows a function that exceeds a configured maximum length (CFQ001). To trigger this, a `max-function-length` is specified on the command line, or can be configured in a `.flake8` or `setup.cfg` file."},"warnings":[{"fix":"Ensure `flake8-functions` is installed in the same environment as `flake8`. Run `flake8` command as usual; no extra configuration is needed for activation.","message":"Flake8 plugins are automatically activated upon installation. There are no direct Python imports required or exposed for `flake8-functions` within your code. Simply `pip install flake8-functions` and `flake8` will pick it up.","severity":"gotcha","affected_versions":"All"},{"fix":"Configure `flake8-functions` settings in a `.flake8` or `setup.cfg` file in your project root, or via command-line flags. For example, to change max function length: `[flake8]\nmax-function-length = 50` or `flake8 --max-function-length=50`.","message":"The default limits for checks (e.g., maximum function length, number of arguments, number of returns) might not align with every project's style guide. For instance, the default `max-function-length` is 100 lines.","severity":"gotcha","affected_versions":"All"},{"fix":"Review the source code for the CFQ003 check if specific functions are unexpectedly flagged or missed. If the check is too strict or not suitable, it can be disabled using `--ignore=CFQ003` in your `flake8` configuration.","message":"The definition of 'pure function' (CFQ003 check) implemented by `flake8-functions` might have specific interpretations or limitations, potentially leading to false positives or negatives depending on your project's context or Python version nuances. The documentation does not extensively detail its exact purity detection logic.","severity":"gotcha","affected_versions":"All"},{"fix":"Always use a Python version compatible with both `flake8-functions` and your chosen version of `flake8`. It's recommended to use Python 3.9+ for modern `flake8` setups. Pin `flake8` and `flake8-functions` versions in your `requirements.txt` or `pyproject.toml` to ensure consistent behavior.","message":"While `flake8-functions` explicitly supports Python 3.7+ (and PyPI lists 3.6-3.10), `flake8` itself has evolving Python version requirements. Newer versions of `flake8` (e.g., `flake8` 7.2.0 requires Python >= 3.9) might implicitly make `flake8-functions` incompatible with older Python versions if your `flake8` dependency is not pinned.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}