Skip to content

Commit

Permalink
Merge branch 'develop' into feature/edtf-formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Nov 7, 2024
2 parents c65bc3e + 5c97e4b commit 5668c52
Show file tree
Hide file tree
Showing 53 changed files with 36,563 additions and 749 deletions.
15 changes: 10 additions & 5 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"files": [
"README.md"
"CONTRIBUTORS.md"
],
"imageSize": 100,
"commit": true,
Expand All @@ -14,7 +14,8 @@
"contributions": [
"code",
"review",
"test"
"test",
"ideas"
]
},
{
Expand All @@ -38,7 +39,9 @@
"avatar_url": "https://avatars.githubusercontent.com/u/1488847?v=4",
"profile": "https://github.com/robcast",
"contributions": [
"data"
"data",
"ideas",
"review"
]
},
{
Expand All @@ -50,7 +53,8 @@
"code",
"review",
"test",
"eventOrganizing"
"eventOrganizing",
"ideas"
]
},
{
Expand All @@ -72,5 +76,6 @@
"repoType": "github",
"repoHost": "https://github.com",
"projectName": "undate-python",
"projectOwner": "dh-tech"
"projectOwner": "dh-tech",
"badgeTemplate": "![All Contributors](https://img.shields.io/github/all-contributors/dh-tech/undate-python?color=ee8449&style=flat-square)"
}
22 changes: 12 additions & 10 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,28 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
cache: 'pip'
cache-dependency-path: '**/setup.cfg'
- name: Install package with dependencies
cache-dependency-path: '**/pyproject.toml'
- name: Install package with development dependencies
run: pip install -e ".[dev]"
if: steps.python-cache.outputs.cache-hit != 'true'

# check code style
- name: Run black
run: black src --check --diff
# check with ruff
- name: Run ruff
run: ruff check

# check docs
- name: Check that documentation can be built
run: tox -e docs
run: sphinx-build docs docs/_build # --fail-on-warning

# check types with mypy
- name: Install mypy
run: pip install mypy
- name: Check types in python src directory; install needed types
run: mypy --install-types --non-interactive src

# use treon to make sure that example notebooks run
- name: Check jupyter notebooks with treon
run: treon
13 changes: 6 additions & 7 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ on:

env:
# python version used to calculate and submit code coverage
COV_PYTHON_VERSION: "3.11"
COV_PYTHON_VERSION: "3.12"

jobs:
python-unit:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.9", "3.10", "3.11", "3.12"]
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
defaults:
run:
working-directory: .
Expand All @@ -30,21 +30,20 @@ jobs:
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: '**/setup.cfg'
cache-dependency-path: '**/pyproject.toml'
- name: Install package with dependencies
run: |
pip install -e ".[dev]"
python -m pip install tox tox-gh-actions
pip install -e ".[test]"
if: steps.python-cache.outputs.cache-hit != 'true'

# for all versions but the one we use for code coverage, run normally
- name: Run unit tests normally
run: tox
run: pytest
if: ${{ matrix.python != env.COV_PYTHON_VERSION }}

# run code coverage in one version only
- name: Run unit tests with code coverage reporting
run: tox -e coverage
run: pytest --cov=undate
if: ${{ matrix.python == env.COV_PYTHON_VERSION }}
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ venv.bak/
# code coverage
.coverage
coverage.xml

# jupyter
.ipynb_checkpoints/
15 changes: 11 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
files: \.py
repos:
- repo: https://github.com/psf/black
rev: 22.10.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: black
- id: ruff
args: [ --select, I, --fix, --exit-non-zero-on-fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
Expand All @@ -12,4 +14,9 @@ repos:
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [numpy]
1 change: 1 addition & 0 deletions .pythonversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Python 3.12.7
47 changes: 41 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,58 @@
# Contributing to Undate - A fuzzy date Python library

# Contributing to undate

Hey there!

If you found your way here that probably means you are curious about how to contribute to this project. This is great! We are always looking for new contributors. If you can't find the information you are looking for in this document or anywhere else in the repo, please consider [opening a ticket](https://github.com/dh-tech/undate-python/issues) so we know there is something we need to address.

## Project Setup
Instructions on how to set up the project locally and how to run the tests can be found [in the Readme file](README.md).
Instructions on how to set up the project locally and how to run the tests can be found in [Developer Notes](DEVELOPER_NOTES.md).

## Submitting Changes
If you would like to contribute by submitting bug fixes, improvements, or new features, please fork the repository and then make a pull request to our main branch when you are ready. For details see [this description of the Forking Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow).

If you would like to contribute by submitting bug fixes, improvements, or new features, please fork the repository and then make a pull request to undate **develop** branch when you are ready. If you haven't contributed like this before, we recommend reading [GitHub's documentation on Contributing to a Project](https://docs.github.com/en/get-started/exploring-projects-on-github/contributing-to-a-project).

We use **git flow** branching conventions, so the current release is on the **main** branch and new feature development happens on **develop**. Pull requests for new features or bug fixes should be made to **develop** for inclusion in the next release. For more details, read a longer explanation of the [Git Flow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)

Recommended branch naming conventions:

- For a new feature, create a branch named `feature/i##-short-name` where `##` is the relevant GitHub issue number (if there is one) and `short-name` is a brief label that relates to the changes or feature

In most cases branches should be created from the most recent **develop** branch. Make sure you check out develop and pull any remote changes.
```sh
git checkout develop
git pull
```

If you have `git flow` installed, you can start, you can use:
```sh
git flow feature start i##-short-name
```

If not, you can do the same thing with git commands:
```sh
git checkout -b feature/i##-short-name
```

When you are ready to contribute your changes, open a pull request from your branch to the main undate repository. Please be sure to link to the GitHub issue in your pull request comments.

Ideally contributions should include documentation and tests for the proposed changes, but if that is a barrier please let us know when you submit a pull request.

Please be aware that any contributions will fall under the existing Apache 2.0 license applied to this software.

## Submitting Bug Reports and Feature Requests

If you find a bug or can think a feature you would really like to see being implemented, you can [create a new issue](https://github.com/dh-tech/undate-python/issues). Please first look through the existing issues, however, to avoid duplication of issues.

If you report a bug, please include any error messages you get and a full description of the steps to reproduce the bug. For new feature requests, please clearly describe the functionality you are looking for and, if applicable, why any existing workflow does not suffice. Please also consider, fixing bugs and implementing new features yourself and submit pull request! :)
If you report a bug, please include any error messages you get and a full description of the steps to reproduce the bug. For new feature requests, please clearly describe the functionality you are looking for and, if applicable, why any existing workflow does not suffice. Please also consider fixing bugs and implementing new features yourself and submitting them via pull request! :)

## Submitting Use Cases and Example Data

We are particularly interested in collecting more use cases and example data where undate would be helpful!

Example data can be added to the [examples/](https://github.com/dh-tech/undate-python/tree/main/examples/) folder by a pull request.

## Getting Help
The best and recommended way to get help is to join the [DHTech Slack](https://dh-tech.github.io/join/) and ask for help there. Only in cases when this is not feasible at all, you can open a new issue and tag it with "Help Request".
The best and recommended way to get help is to join the [DHTech Slack](https://dh-tech.github.io/join/) and ask for help there. Only in cases when this is not feasible at all, you can open a new issue and tag it with "Help Request".

## DHTech
This project started during the DHTech 2022 Hackathon. If you do technical work in the digital humanities and are intersted in meeting like-minded people, [consider joining](https://dh-tech.github.io/join/)!
51 changes: 51 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# All Contributors

We use [All Contributors](https://allcontributors.org/) because we recognize that all kinds of contributions are valuable and important.

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
![All Contributors](https://img.shields.io/github/all-contributors/dh-tech/undate-python?color=ee8449&style=flat-square)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

## Contributors

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ColeDCrawford"><img src="https://avatars.githubusercontent.com/u/16374762?v=4?s=100" width="100px;" alt="Cole Crawford"/><br /><sub><b>Cole Crawford</b></sub></a><br /><a href="https://github.com/dh-tech/undate-python/commits?author=ColeDCrawford" title="Code">💻</a> <a href="https://github.com/dh-tech/undate-python/pulls?q=is%3Apr+reviewed-by%3AColeDCrawford" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/dh-tech/undate-python/commits?author=ColeDCrawford" title="Tests">⚠️</a> <a href="#ideas-ColeDCrawford" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://rlskoeser.github.io"><img src="https://avatars.githubusercontent.com/u/691231?v=4?s=100" width="100px;" alt="Rebecca Sutton Koeser"/><br /><sub><b>Rebecca Sutton Koeser</b></sub></a><br /><a href="https://github.com/dh-tech/undate-python/commits?author=rlskoeser" title="Code">💻</a> <a href="https://github.com/dh-tech/undate-python/pulls?q=is%3Apr+reviewed-by%3Arlskoeser" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/dh-tech/undate-python/commits?author=rlskoeser" title="Tests">⚠️</a> <a href="#blog-rlskoeser" title="Blogposts">📝</a> <a href="#example-rlskoeser" title="Examples">💡</a> <a href="https://github.com/dh-tech/undate-python/commits?author=rlskoeser" title="Documentation">📖</a> <a href="#platform-rlskoeser" title="Packaging/porting to new platform">📦</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/robcast"><img src="https://avatars.githubusercontent.com/u/1488847?v=4?s=100" width="100px;" alt="Robert Casties"/><br /><sub><b>Robert Casties</b></sub></a><br /><a href="#data-robcast" title="Data">🔣</a> <a href="#ideas-robcast" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/dh-tech/undate-python/pulls?q=is%3Apr+reviewed-by%3Arobcast" title="Reviewed Pull Requests">👀</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jdamerow"><img src="https://avatars.githubusercontent.com/u/8881141?v=4?s=100" width="100px;" alt="Julia Damerow"/><br /><sub><b>Julia Damerow</b></sub></a><br /><a href="https://github.com/dh-tech/undate-python/commits?author=jdamerow" title="Code">💻</a> <a href="https://github.com/dh-tech/undate-python/pulls?q=is%3Apr+reviewed-by%3Ajdamerow" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/dh-tech/undate-python/commits?author=jdamerow" title="Tests">⚠️</a> <a href="#eventOrganizing-jdamerow" title="Event Organizing">📋</a> <a href="#ideas-jdamerow" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/maltevogl"><img src="https://avatars.githubusercontent.com/u/20907912?v=4?s=100" width="100px;" alt="Malte Vogl"/><br /><sub><b>Malte Vogl</b></sub></a><br /><a href="https://github.com/dh-tech/undate-python/commits?author=maltevogl" title="Code">💻</a> <a href="https://github.com/dh-tech/undate-python/pulls?q=is%3Apr+reviewed-by%3Amaltevogl" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/dh-tech/undate-python/commits?author=maltevogl" title="Tests">⚠️</a> <a href="https://github.com/dh-tech/undate-python/commits?author=maltevogl" title="Documentation">📖</a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="center" size="13px" colspan="7">
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg">
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
</img>
</td>
</tr>
</tfoot>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

### Related blog posts

(blog-rlskoeser)=
#### [by Rebecca Sutton Koeser](#blog-rlskoeser)
- [Join me for a DHTech hackathon? It’s an un-date!](https://dh-tech.github.io/blog/2023-02-09-hackathon-summary/) 2023-02-09 on DHTech blog
91 changes: 91 additions & 0 deletions DEVELOPER_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Developer instructions

Ready to contribute to `undate`? Here are some instructions to get you started.

## Setup

### Use git to checkout a copy of the repository
```sh
git clone [email protected]:dh-tech/undate-python.git
cd undate-python
```

### Install and initialize git flow

This repository uses [git-flow](https://github.com/nvie/gitflow) branching conventions:
- **main** will always contain the most recent release
- **develop** branch is the latest version of work in progress

Pull requests for new features should be made against the **develop** branch.

We recommended installing git-flow.
1. On OSX, use brew or ports, e.g.: `brew install git-flow`; on Ubuntu/Debian, `apt-get install git-flow`
2. Initialize it in your local copy of this repository: run `git flow init` and accept all the defaults.
3. Use `git flow feature start feature-name` to create a new feature development branch.
4. Feature branches can be merged locally with git flow or by GitHub pull request.
4. Use git flow for releases with `git flow release start x.x.x` and `git flow release finish x.x.x`, where x.x.x is the version number for the new release.

If you cannot or prefer not to install git flow, you can do the equivalent manually.
1. Check out the develop branch: `git checkout develop`
3. Create new feature manually from the develop branch: `git checkout -b feature/xxx-name`

### Create a Python virtual environment

Use a recent version of python 3 (we recommend 3.12). If you use [pyenv](https://github.com/pyenv/pyenv), run `pyenv install` to get the current recommended python version for development (specified in `.pythonversion`).

We highly recommend using a python virtualenv to isolate dependencies, e.g.
```
python3 -m venv .venv
source .venv/bin/activate
```

### Install local version of undate with development python dependencies

Install an editable version of the local package along with python dependencies needed for testing and development.

```sh
pip install -e ".[dev]"
```

### Install pre-commit hooks

We use [pre-commit](https://pre-commit.com/) for automated checks and consistent formatting. If you're planning to contribute, please install these when you set up your local development.

```sh
pre-commit install
```

## Tests, documentation, and other checks

### Running unit tests

Tests can be run with `pytest`.

To run all the tests in a single test file, specify the path, e.g.: `pytest tests/test_dateformat/test_base.py`

To test cases by method name, use `-k`: `pytest -k test_str`

### Check python types

Python typing is currently enforced on pull requests as part of a GitHub Actions Continuous Integration check using `mypy` and via pre-commit hook.

To check types locally:
1. Install the necessary typing libraries (first run only):
```sh
mypy --install-types
```
2. Run `mypy src/` to check types.

### Documentation

Documentation can be built with sphinx. Make sure you have the dependencies installed:

```sh
pip install -e ".[docs]"
```

```sh
sphinx-build docs docs/_build
```

HTML documentation will be generated in `docs/_build/html`
Loading

0 comments on commit 5668c52

Please sign in to comment.