Flake8 lint for trailing commas.
Project description
Note: Forked from PyCQA/flake8-commas to add support for Python 3.12, match statement, and other features. Support for Python version below 3.8 has been dropped, as well as older (5.x) versions of flake8.
Usage
If you are using flake8 it’s as easy as:
pip install https://github.com/PeterJCLaw/flake8-commas.git
Now you can avoid those annoying merge conflicts on dictionary and list diffs.
Errors
Different versions of python require commas in different places. Ignore the errors for languages you don’t use in your flake8 config:
Code |
message |
---|---|
C812 |
missing trailing comma |
C813 |
missing trailing comma in Python 3 |
C814 |
missing trailing comma in Python 2 |
C815 |
missing trailing comma in Python 3.5+ |
C816 |
missing trailing comma in Python 3.6+ |
C818 |
trailing comma on bare tuple prohibited |
C819 |
trailing comma prohibited |
Examples
lookup_table = {
'key1': 'value',
'key2': 'something' # <-- missing a trailing comma
}
json_data = json.dumps({
"key": "value",
}), # <-- incorrect trailing comma. json_data is now a tuple. Likely by accident.
3.0.0 (unreleased)
Support dropped for Python <3.8.
Support added for Python 3.12.
Drop explicit noqa handling; this is handled by flake8 now.
Remove use of pkg_resources in favour of importlib.
CI moved to GitHub Actions.
2.1.0 (2021-10-13)
Remove upper bound on flake8. (Issue #67)
Note: this project is no longer maintained, and now black or https://github.com/asottile/add-trailing-comma is recommended instead. (Issue #63) (Issue #69)
2.0.0 (2018-03-19)
Hide ._base from flake8 –version. (Issue #45)
Update URL to https://github.com/PyCQA/flake8-commas/. (Issue #51)
Add check for trailing commas on bare tuples - C818, thanks to Chris AtLee and Arkadiusz Adamski (PR #52)
1.0.0 (2018-01-04)
No changes from 0.5.1, just releasing the first major version.
0.5.1 (2018-01-02)
Refactor single/multi tuple/subscript to simply count commas in all cases.
Prohibit trailing commas in lambda parameter lists.
Fix a missing trailing comma false positive in subcripts with slices.
Fix a prohibited trailing comma false positve in subscripts with slices.
All (Issue #48)
0.5.0 (2018-01-02)
0.4.3 (2017-04-25)
Enforce trailing commas in subscript tuples and slices again. Regression from 0.4.2 (Issue #42)
0.4.2 (2017-04-18)
0.4.1 (2017-01-18)
Add the framework flake8 trove classifier.
0.4.0 (2017-01-18)
0.3.1 (2017-01-18)
Also parse unpacks with literals. (Issue #30)
0.3.0 (2017-01-16)
0.2.0 (2017-01-13)
First version of flake8-commas with changelog
Fix HTML readme render on PyPI.
Support various parenth_form edge cases.
Merge from flake8-trailing-commas
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flake8-commas-x-3.0.0.dev1.tar.gz
.
File metadata
- Download URL: flake8-commas-x-3.0.0.dev1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47807553fb5a7ae53c0b5ccc4762fe624f305222c51b24b0995090d8f8f8ec72 |
|
MD5 | 4edbdd7d379b1d4ca9a39722aba84bc8 |
|
BLAKE2b-256 | 88f17e0658080cc66fce5da0cbd64b55106ca6224fbf2abd77f587b7d73a89fa |
File details
Details for the file flake8_commas_x-3.0.0.dev1-py3-none-any.whl
.
File metadata
- Download URL: flake8_commas_x-3.0.0.dev1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e469f9cae76bb811d1a4ed432d83fb83cad17c2097be2442cf884f95a64b42b1 |
|
MD5 | 172328df2db35c515580fced4aaf5515 |
|
BLAKE2b-256 | fa0381c40d02c20c343929068d60514c49769acf6947dddc451352212eadf960 |