Skip to content

Commit 9fb2a46

Browse files
authored
Merge pull request #93 from jenskeiner/feature/prek
Feature/prek
2 parents 5636371 + 38f9371 commit 9fb2a46

File tree

7 files changed

+210
-239
lines changed

7 files changed

+210
-239
lines changed

.gitignore

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ parts/
2020
sdist/
2121
var/
2222
wheels/
23+
pip-wheel-metadata/
2324
share/python-wheels/
2425
*.egg-info/
2526
.installed.cfg
@@ -49,7 +50,6 @@ coverage.xml
4950
*.py,cover
5051
.hypothesis/
5152
.pytest_cache/
52-
cover/
5353

5454
# Translations
5555
*.mo
@@ -72,7 +72,6 @@ instance/
7272
docs/_build/
7373

7474
# PyBuilder
75-
.pybuilder/
7675
target/
7776

7877
# Jupyter Notebook
@@ -83,9 +82,7 @@ profile_default/
8382
ipython_config.py
8483

8584
# pyenv
86-
# For a library or package, you might want to ignore these files since the code is
87-
# intended to run in multiple environments; otherwise, check them in:
88-
# .python-version
85+
.python-version
8986

9087
# pipenv
9188
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
@@ -94,30 +91,7 @@ ipython_config.py
9491
# install all needed dependencies.
9592
#Pipfile.lock
9693

97-
# UV
98-
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99-
# This is especially recommended for binary packages to ensure reproducibility, and is more
100-
# commonly ignored for libraries.
101-
#uv.lock
102-
103-
# poetry
104-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105-
# This is especially recommended for binary packages to ensure reproducibility, and is more
106-
# commonly ignored for libraries.
107-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108-
#poetry.lock
109-
110-
# pdm
111-
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112-
#pdm.lock
113-
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114-
# in version control.
115-
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116-
.pdm.toml
117-
.pdm-python
118-
.pdm-build/
119-
120-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
12195
__pypackages__/
12296

12397
# Celery stuff
@@ -154,29 +128,12 @@ dmypy.json
154128
# Pyre type checker
155129
.pyre/
156130

157-
# pytype static type analyzer
158-
.pytype/
159-
160-
# Cython debug symbols
161-
cython_debug/
162-
163131
# PyCharm
164132
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165133
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166134
# and can be added to the global gitignore or merged into this file. For a more nuclear
167135
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168136
.idea/
169137

170-
# PyPI configuration file
171-
.pypirc
172-
173-
# Configuration file.
174-
lintr.yml
175-
176-
support/docs/external/
177-
178-
# VS Code
179-
.vscode
180-
181-
# Windsurf
182-
scratchpad.md
138+
# Ruff linter cache
139+
.ruff_cache

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: check-added-large-files
7+
- id: check-case-conflict
8+
- id: end-of-file-fixer
9+
- id: check-json
10+
- id: check-toml
11+
- id: check-symlinks
12+
- id: check-executables-have-shebangs
13+
- id: mixed-line-ending
214
- repo: https://github.com/asottile/pyupgrade
315
rev: v3.21.2
416
hooks:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# exchange-calendars-extensions-api
2-
This package contains parts of the API of
2+
This package contains parts of the API of
33
[exchange-calendars-extensions](https://pypi.org/project/exchange-calendars-extensions/).
44

5-
To separate the API from the implementation, the API is defined in a separate distribution package
6-
[exchange-calendars-extensions-api](https://pypi.org/project/exchange-calendars-extensions_api/), i.e. this package,
5+
To separate the API from the implementation, the API is defined in a separate distribution package
6+
[exchange-calendars-extensions-api](https://pypi.org/project/exchange-calendars-extensions_api/), i.e. this package,
77
that contains the sub-package `exchange_calendars_extensions.api`.
88

9-
The implementation has been moved to the sub-package `exchange_calendars_extensions.core` and is distributed via
9+
The implementation has been moved to the sub-package `exchange_calendars_extensions.core` and is distributed via
1010
[exchange-calendars-extensions](https://pypi.org/project/exchange-calendars-extensions/).
1111

1212
The package `exchange_calendars_extensions` is now a namespace package that wraps the sub-packages.

pyproject.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
[build-system]
2+
requires = ["hatchling>=1.21.1", "hatch-env-plus>=1.0.0"]
3+
build-backend = "hatchling.build"
4+
15
[project]
26
name = "exchange-calendars-extensions-api"
37
dynamic = ["version"]
48
description = "A package that defines parts of the API of the exchange-calendars-extensions package."
9+
license = "Apache-2.0"
10+
license-files = ["LICENSE"]
511
authors = [
612
{ name = "Jens Keiner", email = "jens.keiner@gmail.com" }
713
]
814
readme = "README.md"
915
requires-python = ">=3.10"
10-
license = { text = "Apache-2.0" }
16+
keywords = ["exchange", "calendar", "trading", "holidays"]
1117
classifiers = [
1218
"Development Status :: 4 - Beta",
1319
"Programming Language :: Python",
@@ -44,9 +50,9 @@ dev = [
4450
"pre-commit>=4,<5"
4551
]
4652

47-
[build-system]
48-
requires = ["hatchling>=1.21.1", "hatch-env-plus>=0.1.0"]
49-
build-backend = "hatchling.build"
53+
[tool.hatch.version]
54+
source = "env-plus"
55+
variable = "PACKAGE_VERSION"
5056

5157
[tool.hatch.build.targets.sdist]
5258
include = [
@@ -62,10 +68,6 @@ exclude = [
6268
sources = ["src"]
6369
only-include = ["src/exchange_calendars_extensions"]
6470

65-
[tool.hatch.version]
66-
source = "env-plus"
67-
variable = "PACKAGE_VERSION"
68-
6971
[tool.pytest.ini_options]
70-
addopts = "--cov=exchange_calendars_extensions.api --cov-report=term-missing --cov-report=html"
72+
addopts = "--cov=exchange_calendars_extensions.api --cov-report=term-missing"
7173
testpaths = ["tests"]

src/exchange_calendars_extensions/api/changes.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import functools
33
from collections import OrderedDict
44
from enum import Enum, unique
5-
from typing import Union, Annotated, Callable
5+
from typing import Union, Annotated
6+
from collections.abc import Callable
67

78
import pandas as pd
89
from pydantic import (
@@ -18,13 +19,12 @@
1819
ConfigDict,
1920
)
2021
from typing_extensions import (
21-
Literal,
2222
Any,
2323
Self,
24-
Concatenate,
2524
ParamSpec,
2625
TypeVar,
2726
)
27+
from typing import Literal, Concatenate
2828

2929

3030
@unique
@@ -155,7 +155,7 @@ def __str__(self):
155155
return f'{{type={self.type.name}, name="{self.name}"}}'
156156

157157

158-
def _to_time(value: Union[dt.time, str]):
158+
def _to_time(value: dt.time | str):
159159
"""
160160
Convert value to time.
161161
@@ -230,7 +230,7 @@ class DayMeta(BaseModel, validate_assignment=True, extra="forbid"):
230230
tags: Tags = []
231231

232232
# Free-form comment.
233-
comment: Union[str, None] = Field(default=None, examples=["This is a comment."])
233+
comment: str | None = Field(default=None, examples=["This is a comment."])
234234

235235
@model_validator(mode="after")
236236
def _canonicalize(self) -> "DayMeta":
@@ -459,7 +459,7 @@ def set_tags(self, meta: DayMeta, tags: Tags) -> DayMeta:
459459

460460
@_with_meta
461461
@validate_call
462-
def set_comment(self, meta: DayMeta, comment: Union[str, None]) -> DayMeta:
462+
def set_comment(self, meta: DayMeta, comment: str | None) -> DayMeta:
463463
"""
464464
Set the comment for a given day.
465465
@@ -482,7 +482,7 @@ def set_comment(self, meta: DayMeta, comment: Union[str, None]) -> DayMeta:
482482

483483
@_with_meta
484484
@validate_call
485-
def set_meta(self, meta: DayMeta, meta0: Union[DayMeta, None]) -> DayMeta:
485+
def set_meta(self, meta: DayMeta, meta0: DayMeta | None) -> DayMeta:
486486
"""
487487
Set the metadata for a given day.
488488

tests/test_changes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def test_set_tags_to_none(self):
293293

294294
@pytest.mark.parametrize(["date"], to_args(VALID_DATES))
295295
@pytest.mark.parametrize(["comment"], to_args(VALID_COMMENTS))
296-
def test_set_comment(self, date: DateLike, comment: Union[str, None]):
296+
def test_set_comment(self, date: DateLike, comment: str | None):
297297
cs = ChangeSet()
298298
cs.set_comment(date, comment)
299299

0 commit comments

Comments
 (0)