python-o365
python-o365 copied to clipboard
PytzUsageWarning
Hello, When I have install the new pytz, I am getting error messages. Program still works as expected.
Warning (from warnings module): File "C:\Users\xxxxxxxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\O365\utils\utils.py", line 932 word = self.protocol.timezone.localize( PytzUsageWarning: The localize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
Thanks, we should update to use fold instead of localize.
Another PytzUsageWarning, from a different location (python 3.10):
/home/lalmeras/.local/share/virtualenvs/kobms-ZwOPWgR8/lib/python3.10/site-packages/O365/utils/windows_tz.py:639: PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
iana_tz.zone if isinstance(iana_tz, tzinfo) else iana_tz)
Yep, I'm aware but don't have the time to change that
Any news on this? The printed warning will be confusing to end-users who use CLI tools that internally use the O365 lib. So far, my workaround (to get rid of the warning) is to simply pass in timezone=pytz.UTC as argument to the Account instance.
This should be fixed with #994 being merged.
It's not fixed though. PyTzDeprecationShim is still used (at least when I debugged it on Windows). See https://github.com/O365/python-o365/blob/47f43383d12809bfb82cc91850589951e76b34da/O365/connection.py#L102 which calls an outdated version (4.3) of the tzlocal library which still uses the PyTzDeprecationShim. Thus, the problem might be fixed by using a more recent tzlocal version, but I did not check.
As @MShekow noted, the problem is that after dropping pytz I don't have changed the requirements for tzlocal to be >=5.0. I'll fix this asap
Fixed in 31e997c32841a85023f329797470897321b102a0