Skip to main content

A flake8 plugin to help you write better list/set/dict comprehensions.

Project description

Flake8 Comprehensions

https://img.shields.io/pypi/v/flake8-comprehensions.svg https://img.shields.io/travis/adamchainz/flake8-comprehensions.svg

A flake8 plugin that helps you write better list/set/dict comprehensions.

  • Free software: ISC license

Installation

Install from pip with:

pip install flake8-comprehensions

It will then automatically be run as part of flake8; you can check it has been picked up with:

$ flake8 --version
2.4.1 (pep8: 1.7.0, pyflakes: 0.8.1, flake8-comprehensions: 1.0.0, mccabe: 0.3.1) CPython 2.7.11 on Darwin

Rules

C400: Unnecessary generator

Complains about unnecessary use of a generator when a list/set/dict comprehension would do:

For example, an unnecessary usage of list() plus a generator, instead of a list comprehension:

  • list(f(x) for x in foo) -> [f(x) for x in foo]

This triggers a message like:

$ flake8 file.py
file.py:1:1: C400 Unnecessary generator - rewrite as a list comprehension.

This works similarly for set() and dict() with generators instead of their respective comprehensions.

History

Pending Release

  • New release notes here

1.0.0 (2016-04-05)

  • C400 rule that complains about an unnecessary usage of a generator when a list/set/dict comprehension would do.

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-comprehensions-1.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

flake8_comprehensions-1.0.0-py2.py3-none-any.whl (4.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file flake8-comprehensions-1.0.0.tar.gz.

File metadata

File hashes

Hashes for flake8-comprehensions-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c5f777c996fb0152128e140f6fa919dfbd9080da2ab12f34041c6a705aae4918
MD5 6a688ad4c6db58756d703fad5b50d770
BLAKE2b-256 4c8ef7fbc6b770c159d6796ab96f5eba01ad9c6526a94b29d45432708d232585

See more details on using hashes here.

File details

Details for the file flake8_comprehensions-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_comprehensions-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c90f61acc01ab213cd1429d3a8c81ca596427496f08ad86b38f67fa67add73c9
MD5 00c1dd828734e3df758316a1a1c4e350
BLAKE2b-256 8eed3a985bed7af375270d4cf10c4dc15c9b876b071039936bbcd1a13503c540

See more details on using hashes here.

Supported by

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