Skip to content

Commit bef2ffc

Browse files
authored
Try using setup.cfg declarative metadata (#403)
* switch to setup.cfg metadata * remove manifest * update setupcfg * update setupcfg * update setupcfg * separate config file * fixup paths * exclude tests * Update setup.cfg * config module * remove old file * package -> nbqa * put manifest back * smaller manifest * move assets back out
1 parent 735dc52 commit bef2ffc

10 files changed

+82
-100
lines changed

.pre-commit-config.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
rev: pylint-2.6.0
2727
hooks:
2828
- id: pylint
29-
exclude: ^docs/conf\.py$
29+
files: ^nbqa/
3030
- repo: https://gitlab.com/pycqa/flake8
3131
rev: 3.8.4
3232
hooks:
@@ -39,18 +39,18 @@ repos:
3939
rev: 5.1.1
4040
hooks:
4141
- id: pydocstyle
42-
exclude: ^docs/
42+
files: ^nbqa/
4343
- repo: https://github.com/econchick/interrogate
4444
rev: 1.3.1
4545
hooks:
4646
- id: interrogate
4747
args: [-v, --fail-under=100]
48-
exclude: ^docs/|__init__\.py$
48+
files: ^nbqa/
4949
- repo: https://github.com/pre-commit/mirrors-mypy
5050
rev: v0.790
5151
hooks:
5252
- id: mypy
53-
exclude: ^docs/
53+
files: ^nbqa/
5454
- repo: https://github.com/asottile/pyupgrade
5555
rev: v2.7.3
5656
hooks:
@@ -71,3 +71,7 @@ repos:
7171
- id: rst-backticks
7272
- id: rst-directive-colons
7373
- id: rst-inline-touching-normal
74+
- repo: https://github.com/asottile/setup-cfg-fmt
75+
rev: v1.15.1
76+
hooks:
77+
- id: setup-cfg-fmt

MANIFEST.in

+1-35
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,4 @@
1-
include LICENSE
2-
include README.md
3-
41
recursive-exclude tests *
2+
recursive-exclude docs *
53
recursive-exclude * __pycache__
64
recursive-exclude * *.py[co]
7-
8-
global-exclude *.bz2
9-
global-exclude *.csv
10-
global-exclude *.dta
11-
global-exclude *.feather
12-
global-exclude *.gz
13-
global-exclude *.h5
14-
global-exclude *.html
15-
global-exclude *.json
16-
global-exclude *.pickle
17-
global-exclude *.png
18-
global-exclude *.pyc
19-
global-exclude *.pyd
20-
global-exclude *.ods
21-
global-exclude *.odt
22-
global-exclude *.sas7bdat
23-
global-exclude *.sav
24-
global-exclude *.so
25-
global-exclude *.xls
26-
global-exclude *.xlsm
27-
global-exclude *.xlsx
28-
global-exclude *.xpt
29-
global-exclude *.xz
30-
global-exclude *.zip
31-
global-exclude *~
32-
global-exclude .DS_Store
33-
global-exclude .git*
34-
global-exclude \#*
35-
36-
prune docs/_build
37-
38-
recursive-include docs *.rst conf.py Makefile make.bat

nbqa/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from nbqa import config_parser, replace_source, save_source
1717
from nbqa.cmdline import CLIArgs
18-
from nbqa.config import Configs
18+
from nbqa.config.config import Configs
1919
from nbqa.find_root import find_project_root
2020
from nbqa.notebook_info import NotebookInfo
2121
from nbqa.optional import metadata

nbqa/config/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Configuration files."""

nbqa/config.py nbqa/config/config.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
from shlex import split
44
from typing import Any, Callable, ClassVar, Dict, List, Mapping, NamedTuple, Optional
55

6+
import toml
7+
from pkg_resources import resource_filename
8+
69
from nbqa.cmdline import CLIArgs
710

811

@@ -18,12 +21,9 @@ class _ConfigSections(NamedTuple): # pylint: disable=R0903
1821
CONFIG_SECTIONS = _ConfigSections()
1922

2023

21-
DEFAULT_CONFIG: Mapping[str, Mapping] = {
22-
"addopts": {"isort": ["--treat-comment-as-code", "# %%"]},
23-
"ignore_cells": {},
24-
"mutate": {},
25-
"config": {},
26-
}
24+
DEFAULT_CONFIG: Mapping[str, Mapping] = toml.load(
25+
resource_filename("nbqa.config", "default_config.toml")
26+
)
2727

2828

2929
class Configs:

nbqa/config/default_config.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[addopts]
2+
isort = ["--treat-comment-as-code", "# %%"]
3+
4+
[config]
5+
6+
[mutate]
7+
8+
[ignore_cells]

nbqa/config_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Callable, List, Optional, Tuple
66

77
from nbqa.cmdline import CLIArgs
8-
from nbqa.config import CONFIG_SECTIONS, Configs
8+
from nbqa.config.config import CONFIG_SECTIONS, Configs
99
from nbqa.toml_parser import parse_from_pyproject_toml
1010

1111

nbqa/toml_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import toml
66

7-
from nbqa.config import CONFIG_SECTIONS, Configs
7+
from nbqa.config.config import CONFIG_SECTIONS, Configs
88

99
_ROOT_CONFIG_KEY: str = "tool"
1010
_NBQA_CONFIG_KEY: str = "nbqa"

setup.cfg

+53-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,56 @@
1-
[bumpversion]
2-
current_version = 0.3.6
1+
[metadata]
2+
name = nbqa
3+
version = attr: nbqa.__version__
4+
description = Run any standard Python code quality tool on a Jupyter Notebook
5+
long_description = file: README.md
6+
long_description_content_type = text/markdown
7+
url = https://github.com/nbQA-dev/nbQA
8+
author = Marco Gorelli, Girish Pasupathy, Sebastian Weigand
9+
license = MIT
10+
license_file = LICENSE
11+
classifiers =
12+
Development Status :: 4 - Beta
13+
Environment :: Console
14+
Framework :: Jupyter
15+
Intended Audience :: Developers
16+
License :: OSI Approved :: MIT License
17+
Natural Language :: English
18+
Operating System :: OS Independent
19+
Programming Language :: Python :: 3
20+
Programming Language :: Python :: 3 :: Only
21+
Programming Language :: Python :: 3.6
22+
Programming Language :: Python :: 3.7
23+
Programming Language :: Python :: 3.8
24+
Programming Language :: Python :: 3.9
25+
Topic :: Software Development :: Quality Assurance
26+
keywords = jupyter, notebook, format, lint
27+
project_urls =
28+
Documentation = https://nbQA.readthedocs.io/en/latest/
29+
Source = https://github.com/nbQA-dev/nbQA
30+
Tracker = https://github.com/nbQA-dev/nbQA/issues
31+
32+
[options]
33+
packages = find:
34+
py_modules = nbqa
35+
install_requires =
36+
toml
37+
importlib_metadata;python_version < '3.8'
38+
python_requires = >=3.6
39+
40+
[options.entry_points]
41+
console_scripts =
42+
nbqa = nbqa.__main__:main
43+
44+
[options.package_data]
45+
nbqa =
46+
config/default_config.toml
47+
48+
[options.packages.find]
49+
exclude =
50+
tests*
51+
52+
[bdist_wheel]
53+
universal = True
354

455
[flake8]
556
ignore = E203,E503,W503,W504

setup.py

+2-50
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,3 @@
1-
#!/usr/bin/env python
1+
from setuptools import setup
22

3-
"""The setup script."""
4-
from pathlib import Path
5-
6-
from setuptools import find_packages, setup
7-
8-
readme = Path("README.md").read_text(encoding="utf8")
9-
10-
requirements = ["toml", "importlib_metadata; python_version < '3.8'"]
11-
12-
setup_requirements = []
13-
14-
test_requirements = []
15-
16-
extra_requirements = {
17-
"toolchain": ["black", "mypy", "isort", "pyupgrade", "flake8", "pylint"]
18-
}
19-
20-
setup(
21-
author="Marco Gorelli, Girish Pasupathy",
22-
python_requires=">=3.6",
23-
classifiers=[
24-
"Development Status :: 4 - Beta",
25-
"Intended Audience :: Developers",
26-
"License :: OSI Approved :: MIT License",
27-
"Natural Language :: English",
28-
"Programming Language :: Python :: 3",
29-
"Programming Language :: Python :: 3.6",
30-
"Programming Language :: Python :: 3.7",
31-
"Programming Language :: Python :: 3.8",
32-
"Programming Language :: Python :: 3.9",
33-
],
34-
description="Run any Python code quality tool on a Jupyter Notebook!",
35-
entry_points={"console_scripts": ["nbqa=nbqa.__main__:main"]},
36-
install_requires=requirements,
37-
license="MIT license",
38-
long_description=readme,
39-
long_description_content_type="text/markdown",
40-
include_package_data=True,
41-
keywords="nbqa",
42-
name="nbqa",
43-
packages=find_packages(include=["nbqa", "nbqa.*"]),
44-
setup_requires=setup_requirements,
45-
test_suite="tests",
46-
tests_require=test_requirements,
47-
extras_require=extra_requirements,
48-
url="https://github.com/nbQA-dev/nbQA",
49-
version="0.3.6",
50-
zip_safe=False,
51-
)
3+
setup()

0 commit comments

Comments
 (0)