diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b7df7f4..70421c42 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: @@ -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: @@ -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 diff --git a/MANIFEST.in b/MANIFEST.in index a51af130..dfb9cbd8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/nbqa/__main__.py b/nbqa/__main__.py index 5ec974f8..57c112b2 100644 --- a/nbqa/__main__.py +++ b/nbqa/__main__.py @@ -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 diff --git a/nbqa/config/__init__.py b/nbqa/config/__init__.py new file mode 100644 index 00000000..26942627 --- /dev/null +++ b/nbqa/config/__init__.py @@ -0,0 +1 @@ +"""Configuration files.""" diff --git a/nbqa/config.py b/nbqa/config/config.py similarity index 96% rename from nbqa/config.py rename to nbqa/config/config.py index d4824f5b..06f06ca5 100644 --- a/nbqa/config.py +++ b/nbqa/config/config.py @@ -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 @@ -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: diff --git a/nbqa/config/default_config.toml b/nbqa/config/default_config.toml new file mode 100644 index 00000000..5093ffec --- /dev/null +++ b/nbqa/config/default_config.toml @@ -0,0 +1,8 @@ +[addopts] +isort = ["--treat-comment-as-code", "# %%"] + +[config] + +[mutate] + +[ignore_cells] diff --git a/nbqa/config_parser.py b/nbqa/config_parser.py index a66630af..95c84318 100644 --- a/nbqa/config_parser.py +++ b/nbqa/config_parser.py @@ -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 diff --git a/nbqa/toml_parser.py b/nbqa/toml_parser.py index f7eb6b2b..1e60407d 100644 --- a/nbqa/toml_parser.py +++ b/nbqa/toml_parser.py @@ -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" diff --git a/setup.cfg b/setup.cfg index 0734f5a5..847e85a4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/setup.py b/setup.py index 8d2b5783..60684932 100644 --- a/setup.py +++ b/setup.py @@ -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()