I want to be able to declare "naive datetime" or "aware datetime" as types
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Der Issue nennt keine Dateien, Tests oder Einstiegspunkte. Beginne damit, den vorgeschlagenen Intersection[]-Typ und den Protokollansatz im verlinkten mypy-Issue zu überprüfen; als abgeschlossen gilt die Arbeit, wenn es eine unterstützte Möglichkeit gibt, naive, aware und pytz-spezifische datetime-Typen zu unterscheiden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100