FreeOpcUa / opcua-asyncio

OPC UA library for python >= 3.7
GNU Lesser General Public License v3.0
1.04k stars 345 forks source link

Resolve timezone deprecation warnings #1661

Closed chrisjbremner closed 2 weeks ago

chrisjbremner commented 2 weeks ago

I see lots of deprecation warnings when running tests in Python 3.12:

DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    await self.current_time_node.write_value(datetime.utcnow())

Instead of the suggested datetime.datetime.now(datetime.UTC), I chose to use datetime.datetime.now(datetime.timezone.utc) since the latter is compatible with Python 3.7 whereas the former is only compatible with Python 3.11.

oroulet commented 2 weeks ago

good work. I never found the 3.7 compatible hack