Skip to content

Commit

Permalink
Added pre-commit configuration and configuration for the tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Dec 5, 2021
1 parent 5716235 commit 3bfe1ad
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 26 deletions.
51 changes: 51 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
hooks:
- id: isort
additional_dependencies: [toml]
- repo: https://github.com/python/black
rev: 21.11b1
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: "^tests/resources/"
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: ["--remove"]
- id: requirements-txt-fixer
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
exclude: test.*
additional_dependencies: [toml]
- repo: https://github.com/terrencepreilly/darglint
rev: v1.8.1
hooks:
- id: darglint
args:
- -v 2
- "--message-template={path}:{line} in `{obj}`:\n {msg_id}: {msg}"
- --strictness=short
- repo: https://github.com/econchick/interrogate
rev: 1.5.0 # or master if you're bold
hooks:
- id: interrogate
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Django Categories

[![Jazzband](https://jazzband.co/static/img/badge.svg)](https://jazzband.co/)
[![codecov](https://codecov.io/gh/jazzband/django-categories/branch/master/graph/badge.svg?token=rW8mpdZqWQ)](https://codecov.io/gh/jazzband/django-categories)

Django Categories grew out of our need to provide a basic hierarchical taxonomy management system that multiple applications could use independently or in concert.

Expand Down
82 changes: 82 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[build-system]
requires = [
"setuptools >= 40.9.0",
"wheel",
]
build-backend = "setuptools.build_meta"

[tool.coverage.run]
branch = true
omit = ["**/test_*.py"]

[tool.coverage.report]
omit = [
"*site-packages*",
"*tests*",
"*.tox*",
]
show_missing = true
exclude_lines = [
"raise NotImplementedError",
"pragma: no-coverage",
]

[tool.interrogate]
ignore-init-method = true
ignore-init-module = false
ignore-magic = true
ignore-semiprivate = false
ignore-private = false
ignore-property-decorators = false
ignore-module = false
ignore-nested-functions = true
ignore-nested-classes = true
ignore-setters = false
fail-under = 95
exclude = ["setup.py", "docs", "build", "test"]
ignore-regex = ["^get$", "^mock_.*", ".*BaseClass.*"]
verbose = 0
quiet = false
whitelist-regex = []
color = true

[tool.isort]
py_version = "38"
force_grid_wrap = 0
use_parentheses = true
line_length = 88
known_typing = ["typing", "types", "typing_extensions", "mypy", "mypy_extensions"]
sections = ["FUTURE", "TYPING", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
include_trailing_comma = true
profile = "black"
multi_line_output = 3
indent = 4
color_output = true

[tool.pydocstyle]
convention = "google"
add-ignore = ["D107", "D200", "D212"]
match = "(?!test_).*\\.py"

[tool.black]
line-length = 119
target-version = ['py38', 'py39']
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
# The following are specific to Black, you probably don't want those.
| blib2to3
| tests/data
| profiling
)/
'''
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
django-mptt==0.11.0
unicode-slugify==0.1.3
django-mptt
unicode-slugify
36 changes: 36 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
[metadata]
name = django-categories
description = A way to handle one or more hierarchical category trees in django.
long_description = file:README.md
long_description_content_type = "text/markdown"
author = Corey Oordt
author_email = coreyoordt@gmail.com
url = http://github.com/jazzband/django-categories
classifiers =
Framework :: Django

[options]
zip_safe=False
include_package_data=True

[options.packages.find]
exclude =
example*
docs
build
include = categories

[flake8]
ignore = D203,W503,E501
exclude =
.git
.tox
docs
build
dist
doc_src
max-line-length = 119

[darglint]
ignore=DAR402

[bdist_wheel]
universal = 1
70 changes: 46 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,53 @@
from setuptools import setup, find_packages
"""The setup script."""

from pathlib import Path

from setuptools import setup

import categories
import os

try:
long_description = open('README.md').read()
except IOError:
long_description = ''

try:
reqs = open(os.path.join(os.path.dirname(__file__), 'requirements.txt')).read()
except (IOError, OSError):
reqs = ''
def parse_reqs(filepath: str) -> list:
"""
Parse a file path containing requirements and return a list of requirements.
Will properly follow ``-r`` and ``--requirements`` links like ``pip``. This
means nested requirements will be returned as one list.
Other ``pip``-specific lines are excluded.
Args:
filepath: The path to the requirements file
Returns:
All the requirements as a list.
"""
path = Path(filepath)
reqstr = path.read_text()
reqs = []
for line in reqstr.splitlines():
line = line.strip()
if line == "":
continue
elif not line or line.startswith("#"):
# comments are lines that start with # only
continue
elif line.startswith("-r") or line.startswith("--requirement"):
_, new_filename = line.split()
new_file_path = path.parent / new_filename
reqs.extend(parse_reqs(new_file_path))
elif line.startswith("-f") or line.startswith("-i") or line.startswith("--"):
continue
elif line.startswith("-Z") or line.startswith("--always-unzip"):
continue
else:
reqs.append(line)
return reqs


requirements = parse_reqs("requirements.txt")

setup(
name='django-categories',
version=categories.get_version(),
description='A way to handle one or more hierarchical category trees in django.',
long_description=long_description,
long_description_content_type="text/markdown",
author='Corey Oordt',
author_email='coreyoordt@gmail.com',
include_package_data=True,
url='http://github.com/jazzband/django-categories',
packages=find_packages(exclude=['example*', ]),
classifiers=[
'Framework :: Django',
],
install_requires=reqs,
dependency_links=[]
install_requires=requirements,
)

0 comments on commit 3bfe1ad

Please sign in to comment.