Skip to content
forked from glyph/DateType

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.

License

Notifications You must be signed in to change notification settings

SonOfLilit/DateType

This branch is 2 commits ahead of, 9 commits behind glyph/DateType:trunk.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

58895da · Aug 1, 2024

History

73 Commits
Feb 8, 2024
Aug 1, 2024
Jun 1, 2022
Jun 1, 2022
Feb 8, 2024
Jun 1, 2022
May 21, 2022
Aug 1, 2024
Nov 27, 2023
Feb 29, 2024
May 21, 2022
Aug 1, 2024
Aug 1, 2024

Repository files navigation

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).

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%