Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 13 additions & 49 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,21 @@ name: ci
on:
push:
branches:
- '*'
pull_request:
branches:
- main
- '*.*.*'
- "dev"
- "feature/*"

jobs:
test_and_coverage:
name: "Test and Coverage (Python ${{ matrix.python-version }})"
runs-on: "ubuntu-latest"

strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install coverage[toml] tox tox-gh-actions
- name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox"
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
verbose: true
run_tests_on_other_versions:
name: "Tests Only (Python ${{ matrix.python-version }})"
tox:
name: "Tox"
runs-on: "ubuntu-latest"

strategy:
matrix:
python-version: ["3.7", "3.8",]

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install tox tox-gh-actions
- name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox"
- uses: "actions/checkout@v5"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install the project
run: uv sync --locked --dev
- name: Install tox
run: uv tool install tox --with tox-uv
- name: "Tox"
run: tox
25 changes: 12 additions & 13 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ jobs:
name: "Docs - Github Pages"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: "Install dependencies"
run: |
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install .
python -m pip install mkdocs-material mkdocstrings[python]
- run: pip install mkdocs-material mkdocstrings[python]
- run: mkdocs gh-deploy --force
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
# - name: "Install dependencies"
# run: |
# python -VV
# python -m site
# python -m pip install --upgrade pip setuptools wheel
# python -m pip install .
# python -m pip install mkdocs-material mkdocstrings[python]
# - run: pip install mkdocs-material mkdocstrings[python]
# - run: mkdocs gh-deploy --force
49 changes: 24 additions & 25 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,33 @@ name: Release
on:
push:
tags:
- 'v*.*.*'
- "v*.*.*"

jobs:
release:
name: Publish to PYPI
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"

- name: "Install dependencies"
- name: Check if on specific branch and exit if not
if: ${{ !contains(github.ref_name, 'main') }}
run: |
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install build

- name: Build package
run: "python -m build"

- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
echo "This workflow is intended for tags on the 'main' branch only."
exit 1
- name: Checkout
uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install Python 3.13
run: uv python install 3.13
- name: Build
run: uv build
- name: Smoke test (wheel)
run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
- name: Smoke test (source distribution)
run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py
# - name: Publish
# run: uv publish
42 changes: 18 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.6.0
- id: check-added-large-files
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.14.6
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
args: [--config, tox.ini]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
# Run the linter.
- id: ruff-check
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.961'
rev: "v1.18.2"
hooks:
- id: mypy
args: [--ignore-missing-imports]
additional_dependencies: [types-python-dateutil]
- id: mypy
args: [--ignore-missing-imports]
additional_dependencies: [types-python-dateutil]
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
7 changes: 0 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# Dateint

[![ci-status](https://github.com/amaralbf/dateint/workflows/ci/badge.svg?event=push&branch=main)](https://github.com/amaralbf/dateint/actions?query=workflow%3Aci+event%3Apush+branch%3Amain)
[![Coverage](https://img.shields.io/codecov/c/github/amaralbf/dateint)](https://codecov.io/github/amaralbf/dateint)
![PYPI](https://img.shields.io/pypi/pyversions/dateint.svg?color=%2334D058)
[![MIT License](https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square)](/LICENSE)
[![Code Style Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black/)


It's very common to store date/datetimes as **integers** or **strings** using formats
such as `YYYYmmdd` or `YYYYmm`. In python, to perform date/datetime arithmetic on those
values, one needs to:
Expand Down
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
print("Hello from dateint!")


if __name__ == "__main__":
main()
52 changes: 44 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,61 @@
[tool.black]
line-length = 88
skip-string-normalization = true
[project]
name = "dateint"
version = "0.1.1"
description = "Helper library for manipulation of formatted date/datetime values."
readme = "README.md"
authors = [
{ name = "Bruno Amaral", email = "amaralbf@gmail.com" }
]
requires-python = ">=3.9"
dependencies = [
"pandas",
"python-dateutil",
]

[tool.isort]
profile = 'black'
[dependency-groups]
dev = [
{include-group = "docs"},
{include-group = "test"},
{include-group = "typing"},
"ipykernel",
"pre-commit"
]

docs = [
"mkdocs-material",
"mkdocstrings[python]"
]

test = [
"pytest",
"coverage[toml]",
"hypothesis[pandas]"
]

typing = [
"mypy",
"types-python-dateutil"
]

[tool.coverage.run]
branch = true
parallel = true
source = ["dateint"]
command_line = "-m pytest tests"

# Exibe no relatório de cobertura o pacote em src/ e não dentro de .tox/
[tool.coverage.paths]
source = ["src", ".tox/*/site-packages"]
source = ["src", ".tox/**/site-packages"]

[tool.coverage.report]
show_missing = true

[tool.mypy]
ignore_missing_imports = true

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
requires = ["uv_build>=0.8.15,<0.9.0"]
build-backend = "uv_build"
38 changes: 0 additions & 38 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/dateint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from .core import add, isoweekday, sub, today, weekday

__version__ = '0.1.0'
__version__ = "0.1.0"
10 changes: 5 additions & 5 deletions src/dateint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from typing import List, Tuple

DEFAULT_FORMAT = '%Y%m%d'
DEFAULT_FORMAT = "%Y%m%d"

DEFAULT_FORMAT_CANDIDATES = [
('%Y%m', 6),
('%Y%m%d', 8),
('%Y%m%d%H%M%S', 14),
('%Y%m%d %H%M%S', 15),
("%Y%m", 6),
("%Y%m%d", 8),
("%Y%m%d%H%M%S", 14),
("%Y%m%d %H%M%S", 15),
]


Expand Down
Loading