Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Removing unused dependency, adding optional dependencies and loosening requests version#104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sg3-141-592 wants to merge1 commit intomaxmind:main
base:main
Choose a base branch
Loading
fromsg3-141-592:master
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion.github/workflows/lint.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,7 +27,7 @@ jobs:
pip install --upgrade pylint black mypy voluptuous-stubs

- name: Install
run:python setup.pyinstall
run:pipinstall -e .[all]

- name: Run mypy
run: mypy geoip2 tests
Expand Down
3 changes: 3 additions & 0 deletionsREADME.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,9 @@ To install the ``geoip2`` module, type:
.. code-block:: bash

$ pip install geoip2
$ pip install geoip2[aiohttp]
$ pip install geoip2[requests]
$ pip install geoip2[all] # Install both requests and aiohttp support

If you are not able to use pip, you may also use easy_install from the
source directory:
Expand Down
46 changes: 35 additions & 11 deletionsgeoip2/webservice.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,12 +27,21 @@

importipaddress
importjson
importsys

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
import sys

fromtypingimportAny,Dict,cast,List,Optional,Type,Union

importaiohttp
importaiohttp.http
importrequests
importrequests.utils
try:
importaiohttp
importaiohttp.http
exceptImportError:
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
pass
aiohttp=None


try:
importrequests
importrequests.utils
exceptImportError:
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
pass
requests=None



importgeoip2
importgeoip2.models
Expand All@@ -48,13 +57,28 @@
fromgeoip2.modelsimportCity,Country,Insights
fromgeoip2.typesimportIPAddress

_AIOHTTP_UA= (
f"GeoIP2-Python-Client/{geoip2.__version__}{aiohttp.http.SERVER_SOFTWARE}"
)

_REQUEST_UA= (
f"GeoIP2-Python-Client/{geoip2.__version__}{requests.utils.default_user_agent()}"
)
# If neither requests or aiohttp is installed then inform user how to
# install them
if"aiohttp"notinsys.modulesand"requests"notinsys.modules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
if"aiohttp"notinsys.modulesand"requests"notinsys.modules:
ifnotrequestsandnotaiohttp:

raiseImportError(
"""To enable geoip2.webservice,
install aiohttp or requests support.
pip install geoip2[aiohttp]
pip install geoip2[requests]
pip install geoip2[all]"""
)


if"aiohttp"insys.modules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
if"aiohttp"insys.modules:
ifaiohttp:

_AIOHTTP_UA= (
f"GeoIP2-Python-Client/{geoip2.__version__}{aiohttp.http.SERVER_SOFTWARE}"
)

if"requests"insys.modules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
if"requests"insys.modules:
ifrequests:

_REQUEST_UA= (
f"GeoIP2-Python-Client/{geoip2.__version__}"
f"{requests.utils.default_user_agent()}"
)


classBaseClient:# pylint: disable=missing-class-docstring, too-few-public-methods
Expand Down
3 changes: 0 additions & 3 deletionsrequirements.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
aiohttp>=3.6.2,<4.0.0
maxminddb>=2.0.0,<3.0.0
requests>=2.24.0,<3.0.0
urllib3>=1.25.2,<2.0.0
2 changes: 2 additions & 0 deletionssetup.cfg
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,3 +23,5 @@ deps =
pytest
mocket
commands = pytest tests
usedevelop = true
extras = aiohttp, requests
5 changes: 5 additions & 0 deletionssetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,11 @@
include_package_data=True,
python_requires=">=3.6",
install_requires=requirements,
extras_require={
"all": ["requests>=2.14.0,<3.0.0", "aiohttp>=3.6.2,<4.0.0"],
"requests": "requests>=2.14.0,<3.0.0",
"aiohttp": "aiohttp>=3.6.2,<4.0.0",
},
tests_require=["mocket>=3.8.9"],
test_suite="tests",
license=geoip2.__license__,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp