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-2025.2.13.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

datetype-2025.2.13-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: datetype-2025.2.13.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for datetype-2025.2.13.tar.gz
Algorithm Hash digest
SHA256 7b309698cb4fcab5c68d08eeac5d9ecc84f02255ba95e5caa8cbe38d8ed3b3f3
MD5 8b8aa9d77bd859aed94e83cf66c181be
BLAKE2b-256 ec1a17b4f99b80dcc850a566c58622aa09b5f9bc531bc9c710d87fbda6f555f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: datetype-2025.2.13-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for datetype-2025.2.13-py3-none-any.whl
Algorithm Hash digest
SHA256 4ade1bffdb8b536c5dc3560a448a24b9ebd6dfcefbd61c491d44a372d0295930
MD5 a119ff83cf0e740222008e457d26215b
BLAKE2b-256 553f61489762dd861d88cbb9671d61da69ff303bf126af95995f16e94dffb36c

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page