wrapkit 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wrapkit-0.4.0/.github/dependabot.yml +19 -0
- wrapkit-0.4.0/.github/workflows/ci.yml +54 -0
- wrapkit-0.4.0/.github/workflows/publish.yml +35 -0
- wrapkit-0.4.0/.gitignore +56 -0
- wrapkit-0.4.0/.pre-commit-config.yaml +31 -0
- wrapkit-0.4.0/.python-version +1 -0
- wrapkit-0.4.0/AGENTS.md +70 -0
- wrapkit-0.4.0/CHANGELOG.md +314 -0
- wrapkit-0.4.0/CLAUDE.md +12 -0
- wrapkit-0.4.0/LICENSE +21 -0
- wrapkit-0.4.0/PKG-INFO +136 -0
- wrapkit-0.4.0/README.md +102 -0
- wrapkit-0.4.0/pyproject.toml +255 -0
- wrapkit-0.4.0/src/wrapkit/__init__.py +23 -0
- wrapkit-0.4.0/src/wrapkit/cache.py +271 -0
- wrapkit-0.4.0/src/wrapkit/cli.py +258 -0
- wrapkit-0.4.0/src/wrapkit/frames.py +301 -0
- wrapkit-0.4.0/src/wrapkit/http.py +819 -0
- wrapkit-0.4.0/src/wrapkit/incremental.py +271 -0
- wrapkit-0.4.0/src/wrapkit/io.py +75 -0
- wrapkit-0.4.0/src/wrapkit/log.py +326 -0
- wrapkit-0.4.0/src/wrapkit/py.typed +0 -0
- wrapkit-0.4.0/tests/conftest.py +26 -0
- wrapkit-0.4.0/tests/test_cache.py +325 -0
- wrapkit-0.4.0/tests/test_cli.py +381 -0
- wrapkit-0.4.0/tests/test_frames.py +169 -0
- wrapkit-0.4.0/tests/test_http.py +589 -0
- wrapkit-0.4.0/tests/test_incremental.py +287 -0
- wrapkit-0.4.0/tests/test_io.py +68 -0
- wrapkit-0.4.0/tests/test_log.py +345 -0
- wrapkit-0.4.0/uv.lock +1291 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Dependabot opens monthly grouped PRs for the uv dependencies and for the
|
|
2
|
+
# GitHub Actions used in the workflows. Security updates arrive as soon as an
|
|
3
|
+
# advisory is published, independent of this schedule.
|
|
4
|
+
version: 2
|
|
5
|
+
updates:
|
|
6
|
+
- package-ecosystem: uv
|
|
7
|
+
directory: /
|
|
8
|
+
schedule:
|
|
9
|
+
interval: monthly
|
|
10
|
+
groups:
|
|
11
|
+
python:
|
|
12
|
+
patterns: ["*"]
|
|
13
|
+
- package-ecosystem: github-actions
|
|
14
|
+
directory: /
|
|
15
|
+
schedule:
|
|
16
|
+
interval: monthly
|
|
17
|
+
groups:
|
|
18
|
+
actions:
|
|
19
|
+
patterns: ["*"]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
quality:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python: ["3.12", "3.13"]
|
|
16
|
+
env:
|
|
17
|
+
UV_PYTHON: ${{ matrix.python }}
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v7
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v10.4.0
|
|
23
|
+
with:
|
|
24
|
+
enable-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Set up Python
|
|
27
|
+
run: uv python install ${{ matrix.python }}
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: uv sync --locked
|
|
31
|
+
|
|
32
|
+
- name: Ruff lint
|
|
33
|
+
run: uv run ruff check --output-format=github .
|
|
34
|
+
|
|
35
|
+
- name: Ruff format check
|
|
36
|
+
run: uv run ruff format --check .
|
|
37
|
+
|
|
38
|
+
- name: Codespell
|
|
39
|
+
run: uv run codespell src tests README.md CHANGELOG.md
|
|
40
|
+
|
|
41
|
+
- name: Deptry
|
|
42
|
+
run: uv run deptry src
|
|
43
|
+
|
|
44
|
+
- name: Docstring coverage (interrogate)
|
|
45
|
+
run: uv run interrogate -c pyproject.toml src tests
|
|
46
|
+
|
|
47
|
+
- name: Type check (mypy)
|
|
48
|
+
run: uv run mypy
|
|
49
|
+
|
|
50
|
+
- name: Type check (ty)
|
|
51
|
+
run: uv run ty check
|
|
52
|
+
|
|
53
|
+
- name: Tests
|
|
54
|
+
run: uv run pytest
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write # required for PyPI Trusted Publishing (OIDC)
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
pypi:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment: pypi
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v7
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v10.4.0
|
|
21
|
+
|
|
22
|
+
- name: Version consistency (tag == pyproject == __version__)
|
|
23
|
+
if: github.event_name == 'release'
|
|
24
|
+
run: |
|
|
25
|
+
pyproject=$(grep -m1 '^version = ' pyproject.toml | sed -E 's/^version = "([^"]+)".*/\1/')
|
|
26
|
+
module=$(grep -m1 '^__version__ = ' src/wrapkit/__init__.py | sed -E 's/^__version__ = "([^"]+)".*/\1/')
|
|
27
|
+
tag="${GITHUB_REF_NAME#v}"
|
|
28
|
+
echo "pyproject=$pyproject module=$module tag=$tag"
|
|
29
|
+
test "$pyproject" = "$module" && test "$pyproject" = "$tag"
|
|
30
|
+
|
|
31
|
+
- name: Build
|
|
32
|
+
run: uv build
|
|
33
|
+
|
|
34
|
+
- name: Publish to PyPI
|
|
35
|
+
run: uv publish
|
wrapkit-0.4.0/.gitignore
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.venv/
|
|
6
|
+
venv/
|
|
7
|
+
.env
|
|
8
|
+
|
|
9
|
+
# Build artifacts
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
|
|
13
|
+
# Tooling caches / reports
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
.coverage
|
|
18
|
+
.coverage.*
|
|
19
|
+
coverage.xml
|
|
20
|
+
htmlcov/
|
|
21
|
+
|
|
22
|
+
# Local cache of downloaded EIA API responses
|
|
23
|
+
.cache/
|
|
24
|
+
|
|
25
|
+
# Default outputs folder: keep the folder, ignore everything written into it
|
|
26
|
+
outputs/*
|
|
27
|
+
!outputs/.gitkeep
|
|
28
|
+
|
|
29
|
+
# OS / editors
|
|
30
|
+
.DS_Store
|
|
31
|
+
.idea/
|
|
32
|
+
.vscode/
|
|
33
|
+
|
|
34
|
+
# Sphinx docs build output
|
|
35
|
+
docs/_build/
|
|
36
|
+
|
|
37
|
+
# LaTeX build files
|
|
38
|
+
*.aux
|
|
39
|
+
*.log
|
|
40
|
+
*.out
|
|
41
|
+
*.toc
|
|
42
|
+
*.bbl
|
|
43
|
+
*.blg
|
|
44
|
+
*.synctex.gz
|
|
45
|
+
*.fls
|
|
46
|
+
*.fdb_latexmk
|
|
47
|
+
*.bcf
|
|
48
|
+
*.run.xml
|
|
49
|
+
*.nav
|
|
50
|
+
*.snm
|
|
51
|
+
*.lof
|
|
52
|
+
*.lot
|
|
53
|
+
*.xdv
|
|
54
|
+
|
|
55
|
+
# Jupyter
|
|
56
|
+
.ipynb_checkpoints/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v6.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: check-toml
|
|
9
|
+
- id: check-added-large-files
|
|
10
|
+
args: ["--maxkb=1024"]
|
|
11
|
+
|
|
12
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
13
|
+
rev: v0.17.3
|
|
14
|
+
hooks:
|
|
15
|
+
- id: ruff-check
|
|
16
|
+
args: ["--fix"]
|
|
17
|
+
- id: ruff-format
|
|
18
|
+
|
|
19
|
+
- repo: https://github.com/codespell-project/codespell
|
|
20
|
+
rev: v2.4.1
|
|
21
|
+
hooks:
|
|
22
|
+
- id: codespell
|
|
23
|
+
additional_dependencies: ["tomli"]
|
|
24
|
+
|
|
25
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
26
|
+
rev: v1.18.2
|
|
27
|
+
hooks:
|
|
28
|
+
- id: mypy
|
|
29
|
+
additional_dependencies:
|
|
30
|
+
- pandas-stubs
|
|
31
|
+
- types-requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
wrapkit-0.4.0/AGENTS.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Agent guide
|
|
2
|
+
|
|
3
|
+
Instructions for AI coding agents working in this repository.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
`wrapkit` is the shared infrastructure of the data-API wrappers in
|
|
8
|
+
`github.com/hmorao95` (logging and redaction, disk cache, retries and throttle,
|
|
9
|
+
tidy frames, incremental updates, file output, python-fire helpers). The
|
|
10
|
+
wrappers depend on it by git tag. The repository is public: it must only hold
|
|
11
|
+
generic code, never a key, token, endpoint secret or anything specific to one
|
|
12
|
+
data source.
|
|
13
|
+
|
|
14
|
+
Layout: `src/wrapkit/` (one module per area, see the README), `tests/`
|
|
15
|
+
(network-free pytest suite).
|
|
16
|
+
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv sync
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`.python-version` pins the local environment to Python 3.12, the supported
|
|
24
|
+
floor. CI runs the checks on 3.12 and 3.13, with `UV_PYTHON` set from the
|
|
25
|
+
matrix. Keep that variable. A `--python` flag on `uv sync` alone does not hold,
|
|
26
|
+
because the next `uv run` reads `.python-version` and rebuilds `.venv` on 3.12.
|
|
27
|
+
|
|
28
|
+
## Quality gate (must pass before every commit)
|
|
29
|
+
|
|
30
|
+
CI runs exactly these on Python 3.12 and 3.13:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv run ruff check .
|
|
34
|
+
uv run ruff format --check .
|
|
35
|
+
uv run codespell src tests README.md CHANGELOG.md
|
|
36
|
+
uv run deptry src
|
|
37
|
+
uv run interrogate -c pyproject.toml src tests
|
|
38
|
+
uv run mypy
|
|
39
|
+
uv run ty check
|
|
40
|
+
uv run pytest # coverage >= 95%
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Do not weaken the gate to make it pass.
|
|
44
|
+
|
|
45
|
+
## Conventions
|
|
46
|
+
|
|
47
|
+
- Google-style docstrings with `Args:` / `Returns:` / `Raises:`; `mypy --strict`;
|
|
48
|
+
`from __future__ import annotations`; exception messages go in a `msg`
|
|
49
|
+
variable first.
|
|
50
|
+
- Behaviour is part of the contract: the wrappers' own test suites rely on it.
|
|
51
|
+
Changing a default, a log line or an error message is a breaking change for
|
|
52
|
+
them; note it in the changelog.
|
|
53
|
+
- Text the user sees in a wrapper (messages in Portuguese for ine-pt-api, for
|
|
54
|
+
example) comes from the caller; wrapkit's own messages are English.
|
|
55
|
+
- Tests never hit the network.
|
|
56
|
+
|
|
57
|
+
## Git and releases
|
|
58
|
+
|
|
59
|
+
- Branch, open a PR, squash-merge once CI is green.
|
|
60
|
+
- **Commit as the repo owner.**
|
|
61
|
+
- Releasing: move `[Unreleased]` under `## [X.Y.Z] - <date>`, bump the version
|
|
62
|
+
in `pyproject.toml` and `src/wrapkit/__init__.py`, `uv lock`, merge, then
|
|
63
|
+
`git tag -a vX.Y.Z` and `gh release create vX.Y.Z`. Wrappers then bump their
|
|
64
|
+
pin, one PR each.
|
|
65
|
+
- Publishing: a published GitHub release triggers
|
|
66
|
+
`.github/workflows/publish.yml` (uv build + `uv publish` via PyPI Trusted
|
|
67
|
+
Publishing, environment `pypi`, no token). It checks that the tag,
|
|
68
|
+
`pyproject.toml` and `__version__` agree before uploading. wrapkit is on PyPI
|
|
69
|
+
from 0.4.0; wrappers may depend on `wrapkit>=X.Y,<X.(Y+1)` instead of a git
|
|
70
|
+
tag, which is what lets a wrapper itself go on PyPI.
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.4.0] - 2026-12-05
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Published on PyPI (`pip install wrapkit`), through a release-triggered
|
|
14
|
+
Trusted Publishing workflow. Package metadata gained classifiers and
|
|
15
|
+
changelog/issues links.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **Breaking:** Python 3.12 is now the minimum supported version (3.10 reached
|
|
20
|
+
end of life in October 2026); 3.10 and 3.11 users keep the last release that
|
|
21
|
+
supports them (0.3.1). CI runs on 3.12 and 3.13.
|
|
22
|
+
- Lock refreshed; soupsieve 4.x (security fixes).
|
|
23
|
+
|
|
24
|
+
## [0.3.1] - 2026-12-05
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Two `AsyncThrottle`s with the same `key` in one event loop each had their
|
|
29
|
+
own asyncio lock, so two clients of one provider could send at the same
|
|
30
|
+
instant. The lock now lives in the key's shared state, one per loop.
|
|
31
|
+
- Two throttles with the same `key` and a `per_day` limit each loaded their
|
|
32
|
+
own daily ledger, so they counted separately and overwrote each other's
|
|
33
|
+
file. The key now has one ledger; if their daily limits differ, the
|
|
34
|
+
stricter one applies.
|
|
35
|
+
|
|
36
|
+
## [0.3.0] - 2026-12-05
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- `RateLimit`: a provider's published request limit (`requests_per_second`,
|
|
41
|
+
`per_minute`, `per_hour`, `per_day`) and its `source`. Its `interval` is the
|
|
42
|
+
strictest spacing of the first three, so no window can be exceeded;
|
|
43
|
+
`describe()` renders it for READMEs and errors.
|
|
44
|
+
- `Throttle(..., limit=, key=, ledger_dir=)` and `AsyncThrottle` enforce a
|
|
45
|
+
`RateLimit` strictly: `requests_per_second` may only slow the client down
|
|
46
|
+
(asking for more raises the new `RateLimitError`), and `None` or `0` means
|
|
47
|
+
the limit's own rate instead of no throttle. Throttles with the same `key`
|
|
48
|
+
share one request history across instances and threads (now thread-safe).
|
|
49
|
+
`per_day` is a rolling 24-hour count kept in
|
|
50
|
+
`~/.cache/wrapkit/rate_limits/<key>.json`; once used up the throttle raises
|
|
51
|
+
the new `QuotaExhausted` before any request is sent. Without `limit`,
|
|
52
|
+
`Throttle` behaves as before.
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- A server's `Retry-After` is no longer cut to `max_wait` (30 s), which made
|
|
57
|
+
clients retry before the server allowed: a 60-second block (GIE, FRED, SSB)
|
|
58
|
+
was retried after 30 s, restarting the block. `RetryPolicy` gains
|
|
59
|
+
`max_retry_after` (default 120 s): a numeric `Retry-After` on a 429 or 503 is
|
|
60
|
+
waited out in full up to that value. A longer one ends the retries:
|
|
61
|
+
`get_with_retries` and `aget_with_retries` return that answer at once and log
|
|
62
|
+
a warning, instead of coming back early. `max_wait` now caps only the
|
|
63
|
+
backoff. New helpers `RetryPolicy.retry_after` and `RetryPolicy.gives_up`.
|
|
64
|
+
|
|
65
|
+
## [0.2.10] - 2026-11-18
|
|
66
|
+
|
|
67
|
+
### Fixed
|
|
68
|
+
|
|
69
|
+
- `DiskCache.get` treats an entry whose file time is ahead of the clock as
|
|
70
|
+
expired. With a positive TTL it used to serve such an entry as fresh until
|
|
71
|
+
the clock passed the file time plus the TTL. A file dated a day ahead (by
|
|
72
|
+
clock skew on a shared cache, or set by anyone who can touch the entry)
|
|
73
|
+
stayed fresh for a day plus the TTL. 0.2.8 fixed this for a TTL of zero
|
|
74
|
+
only. The age is now taken in whole nanoseconds, so an entry read right
|
|
75
|
+
after it is written is never mistaken for one dated ahead. An entry with a
|
|
76
|
+
future time is fetched again and rewritten, and logs `Cache expired`.
|
|
77
|
+
|
|
78
|
+
## [0.2.9] - 2026-11-18
|
|
79
|
+
|
|
80
|
+
### Security
|
|
81
|
+
|
|
82
|
+
- `RedactFilter.install()` now also attaches to `urllib3.connection`,
|
|
83
|
+
`urllib3.poolmanager`, `httpcore.http11` and `httpcore.http2`. urllib3 2.x
|
|
84
|
+
logs the full request URL, query included, at WARNING when a response's
|
|
85
|
+
headers fail to parse (and at INFO when a `PoolManager` follows a
|
|
86
|
+
redirect), and httpcore logs response headers at DEBUG, where a redirect's
|
|
87
|
+
`Location` can repeat the query. A logger's filters only run on records
|
|
88
|
+
created on that logger, so those records reached root, `urllib3` or
|
|
89
|
+
`httpcore` handlers with the key in clear text even with the filter
|
|
90
|
+
installed as documented. `HTTP_LOGGERS` keeps its first three names and
|
|
91
|
+
order and gains the four new ones; a wrapper test that checks its exact
|
|
92
|
+
contents will see the difference.
|
|
93
|
+
- `run()` now masks the `Error: <message>` line it prints for an expected
|
|
94
|
+
error with every `RedactFilter` attached to the `logger` it is given (for a
|
|
95
|
+
`LoggerAdapter`, the logger it wraps), as the DEBUG record of the same
|
|
96
|
+
error already was. A `requests` error quotes the request URL (connection
|
|
97
|
+
refused, timeout, DNS, proxy or TLS failure, or `raise_for_status()`), so
|
|
98
|
+
with the key in the query string the line printed it in clear. It now shows
|
|
99
|
+
`api_key=***`. Wrappers wired as the README shows need no change; a filter
|
|
100
|
+
on a parent logger or a handler is not used. A message without a secret is
|
|
101
|
+
printed exactly as before.
|
|
102
|
+
- `DiskCache.put` now writes through a temp file created exclusively by
|
|
103
|
+
`tempfile.mkstemp` under a random name, instead of the guessable
|
|
104
|
+
`<entry>.<pid>.tmp` opened with a truncating open. Anyone who could write
|
|
105
|
+
the cache directory could plant a link at the old name and make the write
|
|
106
|
+
overwrite the link's target with the caller's privileges, and two puts of
|
|
107
|
+
the same key in one process could break each other. On POSIX, entries are
|
|
108
|
+
now created with mode `0o600` (owner only) instead of `0o666 & ~umask`, so
|
|
109
|
+
a cache directory shared between accounts no longer exposes them to the
|
|
110
|
+
others. `DiskCache.get` treats an entry that is not a regular file (a
|
|
111
|
+
symlink, FIFO or directory) as a miss instead of following or opening it.
|
|
112
|
+
Entry names, their JSON bytes and the atomic swap are unchanged.
|
|
113
|
+
|
|
114
|
+
### Fixed
|
|
115
|
+
|
|
116
|
+
- On Windows, a clone whose path has non-ASCII characters (such as
|
|
117
|
+
`C:\Users\João\...`) left `wrapkit` unimportable when `uv sync` built the
|
|
118
|
+
environment on Python 3.10 or 3.11, which read the editable install's `.pth`
|
|
119
|
+
file in the ANSI code page. The development environment now defaults to
|
|
120
|
+
Python 3.12 (`.python-version`), which reads it as UTF-8. CI still runs the
|
|
121
|
+
checks on 3.10 to 3.13. The README gives workarounds for 3.10 and 3.11.
|
|
122
|
+
|
|
123
|
+
## [0.2.8] - 2026-11-07
|
|
124
|
+
|
|
125
|
+
### Changed
|
|
126
|
+
|
|
127
|
+
- `snake` drops accents and spells out German letters instead of turning
|
|
128
|
+
them into underscores: `Região` becomes `regiao` (was `regi_o`), `Größe`
|
|
129
|
+
`groesse` (was `gr_e`). Other letters, such as `ø`, are kept. Column names
|
|
130
|
+
that had such letters change in the wrappers that use `snake`.
|
|
131
|
+
|
|
132
|
+
### Fixed
|
|
133
|
+
|
|
134
|
+
- `RedactFilter` now also masks secrets in a record's traceback and stack,
|
|
135
|
+
not only its message. `run()` logs every expected error with its
|
|
136
|
+
traceback, and a `requests` error quotes the full URL, so an API key in
|
|
137
|
+
the query string reached `--log-file` in clear text. A traceback that held
|
|
138
|
+
a secret is kept as cleaned text only (the record's `exc_info` is
|
|
139
|
+
cleared); one without a secret is left as it was.
|
|
140
|
+
- `key_strings` (and so `select_new` and `upsert`) now keeps a date's time
|
|
141
|
+
zone and fraction of a second in the key. Times with a zone are keyed in
|
|
142
|
+
UTC, so the two 02:00 hours of the night DST ends no longer share a key,
|
|
143
|
+
and neither do two stamps in the same second; `upsert` used to keep one
|
|
144
|
+
row and drop the other. `upsert` now also reads back stored times with
|
|
145
|
+
mixed UTC offsets (both sides of a DST change) and returns them in the
|
|
146
|
+
fresh column's zone. Naive whole-second dates key exactly as before.
|
|
147
|
+
- `read_existing(text_cols=...)` keeps a missing value missing. On pandas
|
|
148
|
+
before 3 it became the text `"nan"`, which never matched the fresh row's
|
|
149
|
+
key again, so `select_new` returned that row as new on every run.
|
|
150
|
+
- `AsyncThrottle` works under more than one event loop. Its lock used to
|
|
151
|
+
belong to the first loop it queued callers in, so a client reused under a
|
|
152
|
+
second `asyncio.run()` raised `RuntimeError` on its next burst of requests.
|
|
153
|
+
- `period_start` and `period_end` read the SDMX month spelling `2024-M06`
|
|
154
|
+
(also `2024M06`, `2024-M6`, `2024m6`) as June 2024. pandas read it as
|
|
155
|
+
`2024-01-01 00:00:06`, so an `end` bound silently kept only January 1.
|
|
156
|
+
Other year-plus-code labels that are not supported (`2024-M13`,
|
|
157
|
+
`2024-S1`, `2024-W23`) now raise `ValueError` instead of being read as a
|
|
158
|
+
time of day.
|
|
159
|
+
- `DiskCache` with `ttl_seconds=0` (or less) never serves an entry. A file
|
|
160
|
+
written a moment ago could carry a time a hair ahead of the clock, and the
|
|
161
|
+
negative age counted as fresh.
|
|
162
|
+
- `literal_keeping_codes` no longer quotes the zero-led parts of a date or a
|
|
163
|
+
time: `2024-01-15` used to arrive as `2024-'01'-15`, `06/2024` as
|
|
164
|
+
`'06'/2024`. Codes such as `01` are still kept as text.
|
|
165
|
+
- `resolve_out` keeps `./data.csv` (or `.\data.csv`) in the current
|
|
166
|
+
directory, as its docstring says; only a bare name goes to `outputs/`.
|
|
167
|
+
- `get_with_retries` and `aget_with_retries` no longer retry a failed
|
|
168
|
+
certificate check (an `SSLError` is a `ConnectionError`), which used to
|
|
169
|
+
cost about 15 s of backoff before the same error. Other SSL errors, such
|
|
170
|
+
as a dropped handshake, are still retried.
|
|
171
|
+
|
|
172
|
+
## [0.2.7] - 2026-11-07
|
|
173
|
+
|
|
174
|
+
### Fixed
|
|
175
|
+
|
|
176
|
+
- `period_start` and `period_end` now read month labels in any common
|
|
177
|
+
spelling (`2024-6`, `2024/06`, `06/2024`, `2024.06`, `Jun 2024`) as the
|
|
178
|
+
whole month. They used to fall through to `pandas.Timestamp`, which reads
|
|
179
|
+
them as the month's first day, so an `end="2024-6"` bound stopped on
|
|
180
|
+
June 1 instead of covering June. `2024-06`, `202406`, years, quarters and
|
|
181
|
+
full dates behave as before.
|
|
182
|
+
|
|
183
|
+
## [0.2.6] - 2026-11-04
|
|
184
|
+
|
|
185
|
+
### Fixed
|
|
186
|
+
|
|
187
|
+
- `read_existing` now reads stored numbers back exactly. Before pandas 3.1,
|
|
188
|
+
`pd.to_numeric` parsed about one full-precision float in eight one unit in
|
|
189
|
+
the last place off the value `to_csv` wrote, so `select_new` counted those
|
|
190
|
+
unchanged rows as revisions and `update_csv` rewrote them on every run
|
|
191
|
+
(pandas 2.3, which Python 3.10 gets, and 3.0). Floats are now parsed with
|
|
192
|
+
`float`; integers and text that is not a number are handled as before.
|
|
193
|
+
|
|
194
|
+
## [0.2.5] - 2026-11-04
|
|
195
|
+
|
|
196
|
+
### Fixed
|
|
197
|
+
|
|
198
|
+
- `key_strings` (and so `select_new` and `upsert`) now writes a whole
|
|
199
|
+
number spelled as a decimal as an integer: `110.0` and `110` give the same
|
|
200
|
+
key. pandas spells a number by its column's dtype, and a numeric key column
|
|
201
|
+
turns float when a fetch has a gap in it, so the same key used to read
|
|
202
|
+
`110` in one run and `110.0` in the next (or in the stored CSV). A revised
|
|
203
|
+
row was then added next to the old one instead of replacing it. Codes
|
|
204
|
+
without a decimal point, such as `"01"`, are unchanged; a text key spelled
|
|
205
|
+
`"110.0"` now also matches `"110"`.
|
|
206
|
+
|
|
207
|
+
## [0.2.4] - 2026-11-04
|
|
208
|
+
|
|
209
|
+
### Fixed
|
|
210
|
+
|
|
211
|
+
- `read_existing` no longer turns codes such as `"NA"` (Namibia,
|
|
212
|
+
Netherlands Antilles), `"None"` or `"null"` into missing values when it
|
|
213
|
+
reads a stored CSV. Only an empty field counts as missing now. Before,
|
|
214
|
+
those rows lost their key, so every update re-added them as new and the
|
|
215
|
+
file gained a duplicate row with a blank key.
|
|
216
|
+
- `select_new` no longer crashes with "Cannot mask with non-boolean array
|
|
217
|
+
containing NA" when a compared column is a nullable dtype and one side is
|
|
218
|
+
`<NA>`, for example a unit or flag that appears or disappears. That change
|
|
219
|
+
now counts as a revision.
|
|
220
|
+
- `DiskCache.put` writes through a temp file and `Path.replace`, so an
|
|
221
|
+
interrupted write no longer leaves a truncated entry. `DiskCache.get`
|
|
222
|
+
treats an entry it cannot decode as a miss rather than raising on every
|
|
223
|
+
call until the TTL runs out.
|
|
224
|
+
|
|
225
|
+
## [0.2.3] - 2026-11-04
|
|
226
|
+
|
|
227
|
+
### Changed
|
|
228
|
+
|
|
229
|
+
- `.gitignore` now also ignores LaTeX build files (`*.aux`, `*.log`,
|
|
230
|
+
`*.synctex.gz`, `*.fdb_latexmk` and the like) and Jupyter checkpoints
|
|
231
|
+
(`.ipynb_checkpoints/`). No change to the package.
|
|
232
|
+
|
|
233
|
+
## [0.2.2] - 2026-11-03
|
|
234
|
+
|
|
235
|
+
### Added
|
|
236
|
+
|
|
237
|
+
- `snake(name, acronyms=True)` keeps a run of capitals as a word of its own:
|
|
238
|
+
`GDPValue` becomes `gdp_value` and `isCAMRelevant` `is_cam_relevant`. The
|
|
239
|
+
default is unchanged (`gdpvalue`).
|
|
240
|
+
- `upsert(..., numeric_cols=[...])` sorts those columns as numbers, so `9`
|
|
241
|
+
comes before `10` even when the stored rows were read back as text. Other
|
|
242
|
+
sort columns are still compared as text.
|
|
243
|
+
|
|
244
|
+
### Fixed
|
|
245
|
+
|
|
246
|
+
- `read_existing` treats a zero-byte CSV as no prior extract. Before, pandas
|
|
247
|
+
raised `EmptyDataError` on it.
|
|
248
|
+
- `select_new` and `key_strings` build their work frames in one step, and
|
|
249
|
+
`read_existing` returns a consolidated frame after parsing a CSV. With more
|
|
250
|
+
than about 100 value columns, pandas warned about a fragmented frame, an
|
|
251
|
+
error under a warnings-as-errors test setup.
|
|
252
|
+
|
|
253
|
+
## [0.2.1] - 2026-11-02
|
|
254
|
+
|
|
255
|
+
### Fixed
|
|
256
|
+
|
|
257
|
+
- `RedactFilter.redact` masks registered secrets longest first. Before, a
|
|
258
|
+
secret that contains a shorter registered one (a password that includes the
|
|
259
|
+
user name) could be masked in pieces, leaving a fragment in the log line.
|
|
260
|
+
- `configure_logging` accepts a non-string level and rejects it with its usual
|
|
261
|
+
`ValueError`. Fire turns `--log-level 10` into an int, which used to crash on
|
|
262
|
+
`.upper()`.
|
|
263
|
+
- `wrapkit.cli.run` returns what the command returned, as `fire.Fire` does, so
|
|
264
|
+
a wrapper whose `main()` passes that value on can use it.
|
|
265
|
+
|
|
266
|
+
## [0.2.0] - 2026-11-01
|
|
267
|
+
|
|
268
|
+
### Added
|
|
269
|
+
|
|
270
|
+
- `wrapkit.cli.run` takes `error_prefix` (default `"Error"`) and
|
|
271
|
+
`failure_message` (default `"Command failed"`), so a CLI in another language
|
|
272
|
+
prints and logs its own words (ine-pt-api uses Portuguese). The
|
|
273
|
+
defaults keep 0.1.0's output.
|
|
274
|
+
|
|
275
|
+
### Changed
|
|
276
|
+
|
|
277
|
+
- `pre-commit` is no longer a dev dependency: run the hooks with
|
|
278
|
+
`uvx pre-commit` (for example `uvx pre-commit install`). This drops
|
|
279
|
+
`virtualenv` and `filelock` from `uv.lock`; filelock has no patched release
|
|
280
|
+
for Python 3.10.
|
|
281
|
+
|
|
282
|
+
## [0.1.0] - 2026-11-01
|
|
283
|
+
|
|
284
|
+
### Added
|
|
285
|
+
|
|
286
|
+
- `wrapkit.log`: package logger, CLI console and file handlers, plain-text file
|
|
287
|
+
tracebacks, secret redaction on the HTTP loggers.
|
|
288
|
+
- `wrapkit.cache`: `DEFAULT_CACHE_DIR`, `resolve_cache_dir`, `cache_path`,
|
|
289
|
+
`DiskCache`.
|
|
290
|
+
- `wrapkit.http`: `RetryPolicy`, `get_with_retries`, `aget_with_retries`,
|
|
291
|
+
`Throttle`, `AsyncThrottle`, `user_agent`.
|
|
292
|
+
- `wrapkit.frames`: tidy-shape helpers, `as_polars`, `snake`, `period_start`,
|
|
293
|
+
`period_end`.
|
|
294
|
+
- `wrapkit.incremental`: `key_strings`, `select_new`, `read_existing`, `upsert`.
|
|
295
|
+
- `wrapkit.io`: `write_frame`, `frame_format`.
|
|
296
|
+
- `wrapkit.cli`: `resolve_out`, `as_text`, `bind_bool_flags`,
|
|
297
|
+
`literal_keeping_codes`, `set_parse_fns`, `run`.
|
|
298
|
+
|
|
299
|
+
[Unreleased]: https://github.com/hmorao95/wrapkit/compare/v0.4.0...HEAD
|
|
300
|
+
[0.4.0]: https://github.com/hmorao95/wrapkit/compare/v0.3.1...v0.4.0
|
|
301
|
+
[0.3.1]: https://github.com/hmorao95/wrapkit/compare/v0.3.0...v0.3.1
|
|
302
|
+
[0.3.0]: https://github.com/hmorao95/wrapkit/compare/v0.2.10...v0.3.0
|
|
303
|
+
[0.2.10]: https://github.com/hmorao95/wrapkit/compare/v0.2.9...v0.2.10
|
|
304
|
+
[0.2.9]: https://github.com/hmorao95/wrapkit/compare/v0.2.8...v0.2.9
|
|
305
|
+
[0.2.8]: https://github.com/hmorao95/wrapkit/compare/v0.2.7...v0.2.8
|
|
306
|
+
[0.2.7]: https://github.com/hmorao95/wrapkit/compare/v0.2.6...v0.2.7
|
|
307
|
+
[0.2.6]: https://github.com/hmorao95/wrapkit/compare/v0.2.5...v0.2.6
|
|
308
|
+
[0.2.5]: https://github.com/hmorao95/wrapkit/compare/v0.2.4...v0.2.5
|
|
309
|
+
[0.2.4]: https://github.com/hmorao95/wrapkit/compare/v0.2.3...v0.2.4
|
|
310
|
+
[0.2.3]: https://github.com/hmorao95/wrapkit/compare/v0.2.2...v0.2.3
|
|
311
|
+
[0.2.2]: https://github.com/hmorao95/wrapkit/compare/v0.2.1...v0.2.2
|
|
312
|
+
[0.2.1]: https://github.com/hmorao95/wrapkit/compare/v0.2.0...v0.2.1
|
|
313
|
+
[0.2.0]: https://github.com/hmorao95/wrapkit/compare/v0.1.0...v0.2.0
|
|
314
|
+
[0.1.0]: https://github.com/hmorao95/wrapkit/releases/tag/v0.1.0
|
wrapkit-0.4.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This project's agent instructions live in [AGENTS.md](AGENTS.md). Read and follow
|
|
4
|
+
them.
|
|
5
|
+
|
|
6
|
+
@AGENTS.md
|
|
7
|
+
|
|
8
|
+
Key reminders:
|
|
9
|
+
|
|
10
|
+
- Public repository: generic code only, never a secret or source-specific logic.
|
|
11
|
+
- Run the full quality gate before committing.
|
|
12
|
+
- Commit as the repository owner.
|
wrapkit-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hugo Morão
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|