Skip to content

Commit 8a5890b

Browse files
authored
Hatch (#42)
Hatch
1 parent e74f78b commit 8a5890b

62 files changed

Lines changed: 681 additions & 380 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.config/black.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tool.black]
2+
line-length = 79

.config/coveragerc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[run]
2+
source = src
3+
4+
omit = */_version.py
5+
6+
[report]
7+
exclude_also =
8+
from ._version
9+
def __repr__
10+
if self.debug:
11+
if settings.DEBUG
12+
raise AssertionError
13+
raise NotImplementedError
14+
if 0:
15+
if __name__ == .__main__.:
16+
if TYPE_CHECKING:
17+
@(abc\.)?abstractmethod

.config/pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
default_language_version:
2+
python: python3.11
3+
repos:
4+
- repo: https://github.com/psf/black
5+
rev: 23.3.0
6+
hooks:
7+
- id: black
8+
args: [--config, .config/black.toml]
9+
- repo: https://github.com/charliermarsh/ruff-pre-commit
10+
rev: v0.0.267
11+
hooks:
12+
- id: ruff
13+
args: [--config, .config/ruff.toml, --fix, --exit-non-zero-on-fix]
14+
- repo: https://github.com/jazzband/pip-tools
15+
rev: 6.13.0
16+
hooks:
17+
- id: pip-compile
18+
name: pip-compile requirements.txt
19+
files: pyproject.toml
20+
args: [pyproject.toml, --resolver=backtracking, --all-extras, --upgrade, -q, -o, requirements.txt]

.config/pytest.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[pytest]
2+
pythonpath = ../src
3+
addopts = "--color=yes"
4+
log_cli = 1

.config/ruff.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
line-length = 79
2+
exclude = ["_version.py"]
3+
ignore = [
4+
"E501" # Line too long
5+
]
6+
# List of rules: https://beta.ruff.rs/docs/rules/
7+
select = [
8+
"E", # pycodestyle - default
9+
"F", # pyflakes - default
10+
"I" # isort
11+
]
12+
13+
[isort]
14+
known-local-folder = ["hdx"]

CONTRIBUTING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Development
2+
3+
## Environment
4+
5+
Development is currently done using Python 3.11. We recommend using a virtual
6+
environment such as ``venv``:
7+
8+
python3.11 -m venv venv
9+
source venv/bin/activate
10+
11+
In your virtual environment, please install all packages for
12+
development by running:
13+
14+
pip install -r requirements.txt
15+
16+
## Pre-Commit
17+
18+
Also be sure to install `pre-commit`, which is run every time
19+
you make a git commit:
20+
21+
pre-commit install
22+
23+
The configuration file for this project is in a
24+
non-start location. Thus, you will need to edit your
25+
`.git/hooks/pre-commit` file to reflect this. Change
26+
the line that begins with `ARGS` to:
27+
28+
ARGS=(hook-impl --config=.config/pre-commit-config.yaml --hook-type=pre-commit)
29+
30+
With pre-commit, all code is formatted according to
31+
[black]("https://github.com/psf/black") and
32+
[ruff]("https://github.com/charliermarsh/ruff") guidelines.
33+
34+
To check if your changes pass pre-commit without committing, run:
35+
36+
pre-commit run --all-files --config=.config/pre-commit-config.yaml
37+
38+
## Testing
39+
40+
To run the tests and view coverage, execute:
41+
42+
pytest -c .config/pytest.ini --cov hdx --cov-config .config/coveragerc
43+
44+
Follow the example set out already in ``api.rst`` as you write the documentation.
45+
46+
## Packages
47+
48+
[pip-tools](https://github.com/jazzband/pip-tools) is used for
49+
package management. If you’ve introduced a new package to the
50+
source code (i.e.anywhere in `src/`), please add it to the
51+
`project.dependencies` section of
52+
`pyproject.toml` with any known version constraints.
53+
54+
For adding packages for testing or development, add them to
55+
the `test` or `dev` sections under `[project.optional-dependencies]`.
56+
57+
Any changes to the dependencies will be automatically reflected in
58+
`requirements.txt` with `pre-commit`, but you can re-generate
59+
the file without committing by executing:
60+
61+
pre-commit run pip-compile --all-files --config=.config/pre-commit-config.yaml

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
[![Build Status](https://github.com/OCHA-DAP/hdx-python-api/actions/workflows/run-python-tests.yml/badge.svg)](https://github.com/OCHA-DAP/hdx-python-api/actions/workflows/run-python-tests.yml)
2-
[![Coverage Status](https://codecov.io/gh/OCHA-DAP/hdx-python-api/branch/main/graph/badge.svg?token=JpWZc5js4y)](https://codecov.io/gh/OCHA-DAP/hdx-python-api)
3-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1+
[![Build Status](https://github.com/OCHA-DAP/hdx-python-api/actions/workflows/run-python-tests.yaml/badge.svg)](https://github.com/OCHA-DAP/hdx-python-api/actions/workflows/run-python-tests.yaml)
2+
[![Coverage Status](https://coveralls.io/repos/github/OCHA-DAP/hdx-python-api/badge.svg?branch=main&ts=1)](https://coveralls.io/github/OCHA-DAP/hdx-python-api?branch=main)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
43
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
54
[![Downloads](https://img.shields.io/pypi/dm/hdx-python-api.svg)](https://pypistats.org/packages/hdx-python-api)
65

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build:
1111
jobs:
1212
pre_build:
1313
- pip install --upgrade mkdocs
14-
- pip install --upgrade pydoc-markdown
15-
- pydoc-markdown
14+
- pip install pydoc-markdown
15+
- pydoc-markdown documentation/pydoc-markdown.yaml
1616
- mv docs/content/* docs
1717
- rmdir docs/content

0 commit comments

Comments
 (0)