• Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

apply a consistent format to `setup.cfg` files

build status pre-commit.ci status

setup-cfg-fmt

apply a consistent format to setup.cfg files

installation

pip install setup-cfg-fmt

as a pre-commit hook

See pre-commit for instructions

Sample .pre-commit-config.yaml:

-   repo: https://github.com/asottile/setup-cfg-fmt
    rev: v2.3.0
    hooks:
    -   id: setup-cfg-fmt

cli

Consult the help for the latest usage:

$ setup-cfg-fmt --help

what does it do?

sets a consistent ordering for attributes

For example, name and version (the most important metadata) will always appear at the top.

 [metadata]
-version = 1.14.4
-name = pre_commit
+name = pre_commit
+version = 1.14.4

normalizes dashes to underscores in project name

  • pip will normalize names to dashes foo_bar => foo-bar
  • python setup.py sdist produces a filename with the name verbatim
  • pip wheel . produces a filename with an underscore-normalized name
$ # with dashed name
$ python setup.py sdist && pip wheel -w dist .
...
$ ls dist/ | cat
setup_cfg_fmt-0.0.0-py2.py3-none-any.whl
setup-cfg-fmt-0.0.0.tar.gz
$ # with underscore name
$ python setup.py sdist && pip wheel -w dist .
...
$ ls dist/ | cat
setup_cfg_fmt-0.0.0-py2.py3-none-any.whl
setup_cfg_fmt-0.0.0.tar.gz

This makes it easier to upload packages to pypi since they end up with the same filename prefix.

 [metadata]
-name = pre-commit
+name = pre_commit

normalizes dashes to underscores in keys

setuptools allows dashed names but does not document them.

 [metadata]
 name = pre-commit
-long-description = file: README.md
+long_description = file: README.md

adds long_description if README is present

This will show up on the pypi project page

 [metadata]
 name = pre_commit
 version = 1.14.5
+long_description = file: README.md
+long_description_content_type = text/markdown

adds license_file / license / license classifier if LICENSE exists

 [metadata]
 name = pre_commit
 version = 1.14.5
+license = MIT
+license_file = LICENSE
+classifiers =
+    License :: OSI Approved :: MIT License

set python_requires

A few sources are searched for guessing python_requires:

  • the existing python_requires setting itself
  • envlist in tox.ini if present
  • python version classifiers that are already set
  • the --min-py-version argument (currently defaulting to 3.7)

adds python version classifiers

classifiers are generated based on:

  • the python_requires setting
  • the --max-py-version argument (currently defaulting to 3.11)
  • --include-version-classifiers is specified
 name = pkg
 version = 1.0
+classifiers =
+    Programming Language :: Python :: 3
+    Programming Language :: Python :: 3.7
+    Programming Language :: Python :: 3.8
+    Programming Language :: Python :: 3.9
+    Programming Language :: Python :: 3.10
+    Programming Language :: Python :: 3.11

without --include-version-classifiers only the major version will be included:

 name = pkg
 version = 1.0
+classifiers =
+    Programming Language :: Python :: 3

sorts classifiers

 [metadata]
 name = pre_commit
 version = 1.14.5
 classifiers =
-    Programming Language :: Python :: 3
-    License :: OSI Approved :: MIT License
+    License :: OSI Approved :: MIT License
+    Programming Language :: Python :: 3
     Programming Language :: Python :: 3.6

removes empty options in any section

 [options]
-dependency_links =
 python_requires = >= 3.6.1

related projects

More Repositories

1

pyupgrade

A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language.
Python
3,498
star
2

reorder-python-imports

Rewrites source to reorder python imports
Python
731
star
3

git-code-debt

A dashboard for monitoring code debt in a git repository.
Python
573
star
4

all-repos

Clone all your repositories and apply sweeping changes.
Python
534
star
5

babi

a text editor
Python
393
star
6

add-trailing-comma

A tool (and pre-commit hook) to automatically add trailing commas to calls and literals.
Python
338
star
7

dead

dead simple python dead code detection
Python
331
star
8

yesqa

Automatically remove unnecessary `# noqa` comments
Python
265
star
9

astpretty

Pretty print the output of python stdlib `ast.parse`.
Python
189
star
10

detect-test-pollution

a tool to detect test pollution
Python
173
star
11

setup-py-upgrade

upgrade a setup.py to declarative metadata
Python
148
star
12

scratch

Haphazard things.
Python
118
star
13

importtime-waterfall

Generate waterfalls from `-Ximporttime` tracing.
Python
108
star
14

setuptools-golang

A setuptools extension for building cpython extensions written in golang.
Python
98
star
15

dockerfile

Parse a dockerfile into a high-level representation using the official go parser
Go
97
star
16

gh-perf-review

hackety tool to view github PRs for a period
Python
81
star
17

re-assert

show where your regex match assertion failed!
Python
81
star
18

covdefaults

A coverage plugin to provide sensible default settings
Python
63
star
19

tokenize-rt

A wrapper around the stdlib `tokenize` which roundtrips.
Python
50
star
20

flake8-typing-imports

flake8 plugin which checks that typing imports are properly guarded
Python
48
star
21

cfgv

Validate configuration and produce human readable error messages
Python
44
star
22

recipes

One day IoT will catch up and then I can use CI
26
star
23

classify-imports

Utilities for refactoring imports in python-like syntax.
Python
23
star
24

nintendo-microcontrollers

control various nintendo consoles with arduino!
Python
22
star
25

awshelp

awshelp forwards arguments to `aws` unless `-h` or `--help` are present
Python
20
star
26

setuptools-golang-examples

Example extensions written for https://github.com/asottile/setuptools-golang
Go
19
star
27

watch-plz

Ensure all of your repositories are watched.
Python
17
star
28

workflows

reusable github workflows / actions
17
star
29

ukkonen

Implementation of bounded Levenshtein distance (Ukkonen)
C++
16
star
30

onigurumacffi

python cffi bindings for the oniguruma regex engine
Python
16
star
31

color-code

Encodes files as color
Python
16
star
32

wat

my brain is full of wat
Python
11
star
33

personal-puppet

serverless puppet to manage my machines
Puppet
11
star
34

shiny-pokemon-scraper

automatically detect tera raid events with guaranteed shiny pokemon
Python
10
star
35

set-delete-branch-on-merge

github does not provide a way to set the `delete_branch_on_merge` as a default
Python
9
star
36

babi-grammars

pip installable package to provide syntax grammars for babi
Python
7
star
37

rubyvenv

Create no-hassle ruby "virtualenvs". No .bashrc, no shims, no cd-magic.
Python
7
star
38

tessdata

pip installable versions of tesseract-ocr data
Python
6
star
39

setuptools-download

setuptools plugin to download external files
Python
6
star
40

pygments-pre-commit

A pygments lexer for pre-commit output.
Python
6
star
41

t

haphazard code snippets
Python
4
star
42

markdown-code-blocks

Generate html from markdown with code-block highlighting
Python
4
star
43

asottile.github.io

Python
4
star
44

hiera-eyaml-sshagent

A hiera-eyaml plugin which uses the ssh agent connected to `SSH_AUTH_SOCK` to encrypt / decrypt values.
Ruby
4
star
45

kensquared

Kotlin
2
star
46

.github

centralized github metadata for asottile
2
star
47

itl

Python
2
star
48

asottile

2
star
49

gnome-terminal-broken

rip
1
star