Skip to content

feat(dtypes): date / time / duration / decimal dtypes (reine stdlib)#83

Merged
lepy merged 1 commit into
masterfrom
feat/dtypes-date-time-duration-decimal
Jun 29, 2026
Merged

feat(dtypes): date / time / duration / decimal dtypes (reine stdlib)#83
lepy merged 1 commit into
masterfrom
feat/dtypes-date-time-duration-decimal

Conversation

@lepy

@lepy lepy commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Was

Vier neue Attribut-dtypes in der Registry (sdata/dtypes.py), strikt additiv,
reine Standardbibliothek:

dtype Python XSD Coercion
date datetime.date xsd:date ISO YYYY-MM-DD; datetimedate
time datetime.time xsd:time ISO HH:MM:SS
duration datetime.timedelta xsd:duration ISO 8601 (PnW/PnDTnHnMnS, neg. Vorzeichen, Zahl=Sekunden)
decimal decimal.Decimal xsd:decimal exakte Numerik (via str, keine Float-Binär-Artefakte)

Jahre/Monate sind als timedelta nicht darstellbar → klarer DtypeError.

Anbindung (vollständig integriert)

  • DTYPES_INV (Klasse→Name; datetime.datetime bleibt korrekt timestamp, obwohl date-Subklasse)
  • json_default (Roh-Objekte JSON-sicher für Metadata.to_json)
  • DtypeSpec.to_json (kanonische ISO-/Decimal-Strings für JSON-LD @value)
  • semantic._DTYPE_FROM_XSD (from_jsonld-Rückabbildung)
  • lenient/strict=-Coercion wie bei den bestehenden dtypes

Tests / CI

tests/test_dtypes.py: Coercion (gültig/leer/ungültig/strict, datetime→date, neg. Dauer,
Zahl=Sekunden, bool abgelehnt), to_json, json_default, resolve, XSD-Map, JSON-
und JSON-LD-Round-Trip. dtypes.py 244/244 100 %, semantic.py 100 %.

Kanonische CI: 611 passed, 7 skipped, TOTAL 100 %; mkdocs build --strict grün.
ns/context.jsonld-Sync-Guard unberührt (Context enumeriert keine dtypes).

Docs / Release

docs/usage/metadata-jsonld.md (dtype-Liste) + CHANGELOG.md unter [1.3.0] ergänzt
(1.3.0 ist noch nicht veröffentlicht → die dtypes gehören in dieses Release).

Vier neue Attribut-dtypes in der Registry (sdata/dtypes.py), strikt additiv:

- date     -> datetime.date      (xsd:date)    ISO 'YYYY-MM-DD'; datetime -> date
- time     -> datetime.time      (xsd:time)    ISO 'HH:MM:SS'
- duration -> datetime.timedelta (xsd:duration) ISO 8601 (PnW/PnDTnHnMnS,
             negatives Vorzeichen, Zahl=Sekunden); Jahre/Monate nicht als
             timedelta darstellbar -> DtypeError
- decimal  -> decimal.Decimal    (xsd:decimal) exakte Numerik (via str, keine
             Float-Binaer-Artefakte)

Anbindung: DTYPES_INV (Klasse->Name; datetime.datetime bleibt timestamp),
json_default (Roh-Objekte JSON-sicher), DtypeSpec.to_json (kanonische ISO-/
Decimal-Strings fuer JSON-LD @value), semantic._DTYPE_FROM_XSD (from_jsonld-
Rueckabbildung). lenient/strict-Coercion wie bei den bestehenden dtypes.

Tests: Coercion (gueltig/leer/ungueltig/strict), to_json, json_default, resolve,
xsd-Map, JSON- und JSON-LD-Round-Trip. dtypes.py 244/244 100%, semantic.py 100%.
Doku (metadata-jsonld) + CHANGELOG [1.3.0] aktualisiert (1.3.0 noch unveroeffentlicht).

Kanonische CI: 611 passed, 7 skipped, TOTAL 100%; mkdocs --strict gruen.
@lepy lepy merged commit 18ebfec into master Jun 29, 2026
1 of 2 checks passed
@lepy lepy deleted the feat/dtypes-date-time-duration-decimal branch June 29, 2026 14:50
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 medium · 4 minor

Alerts:
⚠ 6 issues (≤ 0 issues of at least minor severity)

Results:
6 new issues

Category Results
Documentation 4 minor
Complexity 2 medium

View in Codacy

🟢 Metrics 49 complexity · 0 duplication

Metric Results
Complexity 49
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant