Incompatible `AwareDateTime` with pytz
See original GitHub issueHello!
As I was trying to introduce strict typing to my project I ran into an issue when integrating pytz
with marshmallow
. It seems that marshmallow
might be requesting too strict of types. The request for only datetime
timezones prevents me from using pytz
with the project (even though they are compatible). The mypy
maintainer suggested that marshmallow
needs to integrate protocol types to be able to solve this problem, though I’ll admit I’m not too sure what that means in this case. For a rundown of the issue please see:
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Specifying timezone aware times in python - datetime
I'm trying to specify a set of timezone aware times in python, using datetime.time objects. However, this does not seem to be supported...
Read more >Incompatibility with datetutil.rrule and pytz.timezone? #102
For some time I've been using pytz's timezone implementation together with dateutil's rrule and have stumbled on an incompatibility several ...
Read more >Making sense of timezones in Python | by Daniel van Flymen
A naive datetime doesn't have a timezone associated with it. An aware one does. ... pytz.localize() is useful for making a naive timezone...
Read more >How to work with dates and time with Python - Opensource.com
When working with timestamps, the best strategy is to use non DST-aware time zones (ideally UTC+00:00). Serializing your datetime objects. The ...
Read more >pytz - Paul Ganssle
This incompatibility is why, as of Python 3.6, the tzinfo documentation ... Whenever you construct an aware datetime from a naive one, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would mark this issue as a bug @deckar01 I’ll try to implement @lafrech patch and submit a PR when I get a chance
My point was that perhaps we should specify datetime.tzinfo as argument type rather than datetime.timezone.
What we actually expect is a tzinfo, not specifically a dt.timezone.
dt.timezone is a convenience class provided by Python core to implement basic timezones. pytz timezones also inherit from tzinfo, which is the right thing to do, not dt.timezone.
The change above should fix the issue IIUC.