Skip to main content

Flake8 plugin enforcing kwargs spacing rules

Project description

pr-tests release-on-merge PyPI version codecov

Flake8 Keyword Arguments with Spaces Plugin

The flake8-kwargs-spaces package is a plugin for Flake8 that enforces consistent spacing around the equals sign (=) in function arguments, in both definitions and calls. By integrating this plugin, developers can ensure uniform code formatting and adherence to style guidelines.

Rules

  • Multiline: When a keyword argument or default is on its own line (e.g. one argument under the def or call), use spaces around =key = 'val'. Violations are reported as EKS100.
  • Inline: When the argument is on the same line as the def/call, or when multiple keyword arguments appear on the same line, use no spaces around =key='val'. Violations are reported as EKS251.

Anti-pattern

def foo(
    key='val'
):
    return key


foo(
    key='val'
)

Best practice

def foo(
    key = 'val'
):
    return key


foo(
    key = 'val'
)

Still anti-pattern

def foo(key = 'val'):
    return key


foo(key = 'val')

Still best practice

def foo(key='val'):
    return key


foo(key='val')

Installation

From PyPI (once published):

pip install flake8-kwargs-spaces

From source (development or before first publish):

  1. Clone the repository and enter it:

    git clone git@github.com:sahargavriely/flake8-kwargs-spaces.git
    cd flake8-kwargs-spaces
    
  2. Run the installation script, then activate the virtual environment:

    ./scripts/install.sh
    source venv/bin/activate
    
  3. (Optional) Run the test suite to verify everything works:

    pytest tests/
    
  4. The install script builds a wheel under wheels/. To use the plugin with Flake8, install that wheel in the environment where you want the plugin enforced:

    pip install ./wheels/flake8_kwargs_spaces-*.whl
    
  5. To avoid conflicts with Flake8’s built-in E251 rule, add a setup.cfg (or use your existing one) with:

    [flake8]
    ignore = E251
    
  6. (Optional) Enable pre-commit hooks:

    pre-commit install --hook-type pre-commit --hook-type pre-push
    pre-commit run --all-files
    pre-commit run --hook-stage pre-push --all-files
    

License

MIT. See LICENSE.

Thanks

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_kwargs_spaces-0.1.8.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flake8_kwargs_spaces-0.1.8-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file flake8_kwargs_spaces-0.1.8.tar.gz.

File metadata

  • Download URL: flake8_kwargs_spaces-0.1.8.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flake8_kwargs_spaces-0.1.8.tar.gz
Algorithm Hash digest
SHA256 4b107383f3b3b7ecdd5c662de6f7b5b4f8d117223abf278da7818dfbdc267684
MD5 10ba0a2deae0f1c3ab5b9888f7487791
BLAKE2b-256 fbeb3f5ffaaf19b923377220f6d0c4051d64159df7ec084d617fbd6151db2595

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_kwargs_spaces-0.1.8.tar.gz:

Publisher: release-on-merge.yml on sahargavriely/flake8-kwargs-spaces

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flake8_kwargs_spaces-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_kwargs_spaces-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 c24ed644d906f884a6d361ece5bfd2d880885335fb60a5a1f9a1ea8e81e275e3
MD5 e17f2c7513c191cdb3c6611158f52e6f
BLAKE2b-256 4566b9f902bf6216eda03a29a1eabc514620c8c8f4c9cbec5b8be37c975d5ab4

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_kwargs_spaces-0.1.8-py3-none-any.whl:

Publisher: release-on-merge.yml on sahargavriely/flake8-kwargs-spaces

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page