{"id":8211,"library":"hacking","title":"OpenStack Hacking Guideline Enforcement","description":"Hacking is an OpenStack project that provides a set of Flake8 plugins to enforce the OpenStack Hacking Guidelines for Python code. It helps developers maintain consistent code style and identify common pitfalls specific to the OpenStack development community. The current version is 8.0.0, and it follows a release cadence tied to OpenStack cycles, with updates typically occurring every few months or as new guideline enforcement is required.","status":"active","version":"8.0.0","language":"en","source_language":"en","source_url":"https://github.com/openstack/hacking","tags":["linter","code quality","flake8 plugin","openstack","style guide"],"install":[{"cmd":"pip install flake8 hacking","lang":"bash","label":"Install Flake8 and Hacking"}],"dependencies":[{"reason":"Hacking is a Flake8 plugin and requires Flake8 to function.","package":"flake8"}],"imports":[],"quickstart":{"code":"mkdir my_project\ncd my_project\necho \"def my_func( value ):\\n    # H301: no space after parameters\\n    pass\" > app.py\npip install flake8 hacking\nflake8 app.py","lang":"bash","description":"This quickstart demonstrates how to install `flake8` and `hacking`, create a sample Python file with a common OpenStack hacking violation (H301), and then run `flake8` to see the generated warning. `hacking` automatically integrates its checks with `flake8` upon installation."},"warnings":[{"fix":"Upgrade your Python environment to 3.10+ or pin `hacking` to a compatible older version (e.g., `hacking<8.0.0`) if Python upgrade is not feasible.","message":"`hacking` version 8.0.0 and newer requires Python 3.10 or higher. Projects on older Python versions must use an older `hacking` release.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Ensure `flake8>=6.0.0` is installed in your environment alongside `hacking`. Use `pip install --upgrade flake8`.","message":"`hacking` version 8.0.0 and newer requires `flake8` version 6.0.0 or higher. Older `flake8` versions are incompatible.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Instead of `import hacking`, run `flake8` from your command line in your project directory. `hacking` contributes checks that `flake8` then executes.","message":"The `hacking` library is a `flake8` plugin and is not designed for direct import and usage in Python code. Its checks are automatically discovered and applied by `flake8`.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"`hacking` is a `flake8` plugin, not a library for direct import. Ensure it's installed (`pip install hacking`) and then run `flake8` from your terminal.","cause":"Attempting to import `hacking` directly into a Python script.","error":"ImportError: No module named 'hacking'"},{"fix":"Remove `--select Hxxx` arguments. `hacking` checks are automatically included. If you need to enable/disable specific checks, use a `.flake8` or `pyproject.toml` configuration file (e.g., `[flake8]\\nignore = H301` to ignore).","cause":"Trying to explicitly enable or select `hacking` checks (e.g., H301) via command-line arguments, which are already integrated by `hacking`.","error":"flake8: error: unrecognized arguments: --select H301"}]}