I want to be able to declare "naive datetime" or "aware datetime" as types
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
La issue non indica file, test o punti di ingresso. Inizia esaminando il tipo Intersection[] proposto e l’approccio basato sui protocolli nella issue di mypy collegata; il lavoro sarà completato quando sarà disponibile un modo supportato per distinguere i tipi datetime naive, aware e specifici di pytz.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100