Skip to content

Commit 1123a2f

Browse files
Update user-agent value passed by the library
This fixes #38.
1 parent 0092942 commit 1123a2f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

ipregistry/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
name = "ipregistry"
22

3-
from .version import __version__
4-
53
from .cache import *
64
from .core import *
75
from .json import *

ipregistry/request.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
"""
16-
16+
import importlib
1717
import json
1818
import sys
1919
import urllib.parse
@@ -22,7 +22,6 @@
2222

2323
import requests
2424

25-
from .__init__ import __version__
2625
from .model import (ApiError, ApiResponse, ApiResponseCredits, ApiResponseThrottling, AutonomousSystem,
2726
ClientError, IpInfo, LookupError, RequesterAutonomousSystem, RequesterIpInfo,
2827
RequesterUserAgent, UserAgent)
@@ -248,8 +247,15 @@ def __create_api_error(response):
248247
raise ClientError("HTTP Error occurred, but no response was received.")
249248

250249
def __headers(self):
250+
python_version = sys.version.split()[0]
251+
lib_version = importlib.metadata.version('ipregistry')
251252
return {
252253
"authorization": "ApiKey " + self._config.api_key,
253254
"content-type": "application/json",
254-
"user-agent": "Ipregistry/Python" + str(sys.version_info[0]) + "/" + __version__
255+
"user-agent":
256+
"Ipregistry/" +
257+
lib_version +
258+
" (Library; Python/" +
259+
python_version +
260+
"; +https://github.com/ipregistry/ipregistry-python)"
255261
}

ipregistry/version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)