Skip to main content

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: v3.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 if LICENSE exists

 [metadata]
 name = pre_commit
 version = 1.14.5
+license = MIT
+license_file = 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

adds python version classifiers

classifiers are generated based on:

  • the python_requires setting
  • the --max-py-version argument
  • --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
+    Programming Language :: Python :: 3
+    Programming Language :: Python :: 3.6

removes empty options in any section

 [options]
-dependency_links =
 python_requires = >= 3.6.1

Metadata

Release files for setup-cfg-fmt 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for setup-cfg-fmt 3.3.0
File Size Uploaded
setup_cfg_fmt-3.3.0.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for setup-cfg-fmt 3.3.0
File Interpreter ABI Platform
setup_cfg_fmt-3.3.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.7 kB

Release files / setup_cfg_fmt-3.3.0.tar.gz

Download URL setup_cfg_fmt-3.3.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
eeaca667a4d1e48eafff7b36d57f8bbc6561705085f62672b26f211d6b0adcb4
BLAKE2b-256 checksum
How to use checksums
f53bb7b1b52970b2f309c09428d5b2ba99c405de96c8070a7862f9138bfc521d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / setup_cfg_fmt-3.3.0-py2.py3-none-any.whl

Download URL setup_cfg_fmt-3.3.0-py2.py3-none-any.whl
Size 8.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
af0c9cde0ddb24b7dbdac1885059550b5070b44289b92bb18e93776a2f408a05
BLAKE2b-256 checksum
How to use checksums
61aea5e52df3afb248eb51283d9bb4ccc88f3187c20e1412387761da19413bb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

3.3.0 This release

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.9.0

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.20.2

2 release files

1.20.0

2 release files

1.19.0

2 release files

1.17.0

2 release files

1.16.0

2 release files

1.15.1

2 release files

1.15.0

2 release files

1.11.0

2 release files

1.9.0

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page