Skip to content

Commit

Permalink
Switch to importlib.metadata from the deprecated pkg_resources mo…
Browse files Browse the repository at this point in the history
…dule (#207)
  • Loading branch information
puddly authored Mar 29, 2023
1 parent 9b959dc commit a73b278
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions zigpy_znp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import itertools
import contextlib
import dataclasses
import importlib.metadata
from collections import Counter, defaultdict

import zigpy.state
import async_timeout
import pkg_resources
import zigpy.zdo.types as zdo_t
import zigpy.exceptions
from zigpy.exceptions import NetworkNotFormed
Expand Down Expand Up @@ -136,10 +136,9 @@ async def _load_network_info(self, *, load_devices=False):
)

version = await self.request(c.SYS.Version.Req())
package_version = pkg_resources.get_distribution("zigpy_znp").version

network_info = zigpy.state.NetworkInfo(
source=f"zigpy-znp@{package_version}",
source=f"zigpy-znp@{importlib.metadata.version('zigpy-znp')}",
extended_pan_id=nib.extendedPANID,
pan_id=nib.nwkPanId,
nwk_update_id=nib.nwkUpdateId,
Expand Down
5 changes: 2 additions & 3 deletions zigpy_znp/tools/network_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import asyncio
import logging
import datetime
import importlib.metadata

import zigpy.state
import pkg_resources

import zigpy_znp.types as t
from zigpy_znp.api import ZNP
Expand Down Expand Up @@ -84,8 +84,7 @@ async def backup_network(znp: ZNP) -> t.JSONType:

now = datetime.datetime.now().astimezone()

package_version = pkg_resources.get_distribution("zigpy_znp").version
obj["metadata"]["source"] = f"zigpy-znp@{package_version}"
obj["metadata"]["source"] = f"zigpy-znp@{importlib.metadata.version('zigpy-znp')}"
obj["metadata"]["internal"] = {
"creation_time": now.isoformat(timespec="seconds"),
"zstack": {
Expand Down

0 comments on commit a73b278

Please sign in to comment.