Skip to content

Commit

Permalink
Try using setup.cfg declarative metadata (#403)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MarcoGorelli authored Oct 31, 2020
1 parent 735dc52 commit bef2ffc
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 100 deletions.
12 changes: 8 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
rev: pylint-2.6.0
hooks:
- id: pylint
exclude: ^docs/conf\.py$
files: ^nbqa/
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
Expand All @@ -39,18 +39,18 @@ repos:
rev: 5.1.1
hooks:
- id: pydocstyle
exclude: ^docs/
files: ^nbqa/
- repo: https://github.com/econchick/interrogate
rev: 1.3.1
hooks:
- id: interrogate
args: [-v, --fail-under=100]
exclude: ^docs/|__init__\.py$
files: ^nbqa/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
hooks:
- id: mypy
exclude: ^docs/
files: ^nbqa/
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.3
hooks:
Expand All @@ -71,3 +71,7 @@ repos:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.15.1
hooks:
- id: setup-cfg-fmt
36 changes: 1 addition & 35 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,38 +1,4 @@
include LICENSE
include README.md

recursive-exclude tests *
recursive-exclude docs *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

global-exclude *.bz2
global-exclude *.csv
global-exclude *.dta
global-exclude *.feather
global-exclude *.gz
global-exclude *.h5
global-exclude *.html
global-exclude *.json
global-exclude *.pickle
global-exclude *.png
global-exclude *.pyc
global-exclude *.pyd
global-exclude *.ods
global-exclude *.odt
global-exclude *.sas7bdat
global-exclude *.sav
global-exclude *.so
global-exclude *.xls
global-exclude *.xlsm
global-exclude *.xlsx
global-exclude *.xpt
global-exclude *.xz
global-exclude *.zip
global-exclude *~
global-exclude .DS_Store
global-exclude .git*
global-exclude \#*

prune docs/_build

recursive-include docs *.rst conf.py Makefile make.bat
2 changes: 1 addition & 1 deletion nbqa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from nbqa import config_parser, replace_source, save_source
from nbqa.cmdline import CLIArgs
from nbqa.config import Configs
from nbqa.config.config import Configs
from nbqa.find_root import find_project_root
from nbqa.notebook_info import NotebookInfo
from nbqa.optional import metadata
Expand Down
1 change: 1 addition & 0 deletions nbqa/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Configuration files."""
12 changes: 6 additions & 6 deletions nbqa/config.py → nbqa/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from shlex import split
from typing import Any, Callable, ClassVar, Dict, List, Mapping, NamedTuple, Optional

import toml
from pkg_resources import resource_filename

from nbqa.cmdline import CLIArgs


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


DEFAULT_CONFIG: Mapping[str, Mapping] = {
"addopts": {"isort": ["--treat-comment-as-code", "# %%"]},
"ignore_cells": {},
"mutate": {},
"config": {},
}
DEFAULT_CONFIG: Mapping[str, Mapping] = toml.load(
resource_filename("nbqa.config", "default_config.toml")
)


class Configs:
Expand Down
8 changes: 8 additions & 0 deletions nbqa/config/default_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[addopts]
isort = ["--treat-comment-as-code", "# %%"]

[config]

[mutate]

[ignore_cells]
2 changes: 1 addition & 1 deletion nbqa/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Callable, List, Optional, Tuple

from nbqa.cmdline import CLIArgs
from nbqa.config import CONFIG_SECTIONS, Configs
from nbqa.config.config import CONFIG_SECTIONS, Configs
from nbqa.toml_parser import parse_from_pyproject_toml


Expand Down
2 changes: 1 addition & 1 deletion nbqa/toml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import toml

from nbqa.config import CONFIG_SECTIONS, Configs
from nbqa.config.config import CONFIG_SECTIONS, Configs

_ROOT_CONFIG_KEY: str = "tool"
_NBQA_CONFIG_KEY: str = "nbqa"
Expand Down
55 changes: 53 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
[bumpversion]
current_version = 0.3.6
[metadata]
name = nbqa
version = attr: nbqa.__version__
description = Run any standard Python code quality tool on a Jupyter Notebook
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/nbQA-dev/nbQA
author = Marco Gorelli, Girish Pasupathy, Sebastian Weigand
license = MIT
license_file = LICENSE
classifiers =
Development Status :: 4 - Beta
Environment :: Console
Framework :: Jupyter
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Natural Language :: English
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Software Development :: Quality Assurance
keywords = jupyter, notebook, format, lint
project_urls =
Documentation = https://nbQA.readthedocs.io/en/latest/
Source = https://github.com/nbQA-dev/nbQA
Tracker = https://github.com/nbQA-dev/nbQA/issues

[options]
packages = find:
py_modules = nbqa
install_requires =
toml
importlib_metadata;python_version < '3.8'
python_requires = >=3.6

[options.entry_points]
console_scripts =
nbqa = nbqa.__main__:main

[options.package_data]
nbqa =
config/default_config.toml

[options.packages.find]
exclude =
tests*

[bdist_wheel]
universal = True

[flake8]
ignore = E203,E503,W503,W504
Expand Down
52 changes: 2 additions & 50 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,3 @@
#!/usr/bin/env python
from setuptools import setup

"""The setup script."""
from pathlib import Path

from setuptools import find_packages, setup

readme = Path("README.md").read_text(encoding="utf8")

requirements = ["toml", "importlib_metadata; python_version < '3.8'"]

setup_requirements = []

test_requirements = []

extra_requirements = {
"toolchain": ["black", "mypy", "isort", "pyupgrade", "flake8", "pylint"]
}

setup(
author="Marco Gorelli, Girish Pasupathy",
python_requires=">=3.6",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
description="Run any Python code quality tool on a Jupyter Notebook!",
entry_points={"console_scripts": ["nbqa=nbqa.__main__:main"]},
install_requires=requirements,
license="MIT license",
long_description=readme,
long_description_content_type="text/markdown",
include_package_data=True,
keywords="nbqa",
name="nbqa",
packages=find_packages(include=["nbqa", "nbqa.*"]),
setup_requires=setup_requirements,
test_suite="tests",
tests_require=test_requirements,
extras_require=extra_requirements,
url="https://github.com/nbQA-dev/nbQA",
version="0.3.6",
zip_safe=False,
)
setup()

0 comments on commit bef2ffc

Please sign in to comment.