I want to be able to declare "naive datetime" or "aware datetime" as types
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Feature
I would like to be able to have a way to say foo: datetime but know that foo either:
- definitely doesn't have a tzinfo
- has a tzinfo
- has a tzinfo that specifically is / isn't from pytz
This could be resolved by an Intersection[] type as described in https://github.com/python/mypy/issues/2087 and a protocol that defines the tzinfo attribute appropriately.
Pitch
My database layer can only persist datetimes with a timezone; my timezone parsing code has portions where I want to make sure I haven't associated a timezone yet because to do so and then convert while replacing it would be an error. Really, naive datetimes and aware datetimes are subtly, but profoundly different types of objects, and their arithmetic represents different types of deltas.
Also, pytz requires different sorts of logic on arithmetic and comparison (i.e. possibly normalize is required) than other zoneinfo objects.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue ではファイル、テスト、エントリポイントが指定されていません。まず、リンク先の mypy issue にある提案された Intersection[] 型とプロトコルアプローチを確認してください。完了条件は、naive、aware、pytz 固有の datetime 型を区別するためのサポートされた方法が実現されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100