Skip to main content

A type wrapper for the standard library `datetime` that supplies stricter checks, such as making 'datetime' not substitutable for 'date', and separating out Naive and Aware datetimes into separate, mutually-incompatible types.

Project description

DateType

A Workaround

DateType is a workaround for this bug to demonstrate that we could have a type-checking-time wrapper for datetime that doesn't change (or almost doesn't change) the implementation, but fixes up two very annoying behaviors of the stdlib datetime module:

  1. a datetime now won't type-check as a date - it still inherits at runtime (the implementation is, after all, not changed) but it doesn't inherit at type-time.

  2. there are separate types for naive and aware datetimes.

There's a very small bit of implementation glue (concrete @classmethods for construction on the Naive and Aware types, and a few functions that do runtime checks to convert to/from stdlib types).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datetype-2023.9.28.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

datetype-2023.9.28-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file datetype-2023.9.28.tar.gz.

File metadata

  • Download URL: datetype-2023.9.28.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for datetype-2023.9.28.tar.gz
Algorithm Hash digest
SHA256 2358cf269c5f6e78e37f09cae24750e4956df9dbfee5116d591f868f9b8bbb8c
MD5 80e07417516c2b83166c4ef3cbaa869c
BLAKE2b-256 277d6ae5301fdd39701a71d00a5cb762b6976a7ad2bf60076c68a765ebab5ff3

See more details on using hashes here.

File details

Details for the file datetype-2023.9.28-py3-none-any.whl.

File metadata

File hashes

Hashes for datetype-2023.9.28-py3-none-any.whl
Algorithm Hash digest
SHA256 02c2044005cd70fa02d3dc143a25b466c87207fe00554c45c3d6b4d073f5796b
MD5 345f355403e2e976f4b1cf3628c1e3f4
BLAKE2b-256 7b6a936d909803cf9e547d8effcc0c45226862813c3a2d31ecb0b8edfea5976f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page