From 90b4007cb4b60b20a7dd3adc98edc66b65d0c46a Mon Sep 17 00:00:00 2001 From: uneekvu <45471690+uneekvu@users.noreply.github.com> Date: Fri, 30 Nov 2018 23:29:02 -0500 Subject: [PATCH] Upversion Django to the latest, Add deprecation warning for 1.0 to be removed in 3.0 (#46) * add deprecation warning, up version Django to latest, update travis.ci * style fix * drop 3.4 support for 2.1.3 --- .travis.yml | 14 ++++++++------ .vscode/settings.json | 3 +++ CHANGELOG.md | 6 ++++++ README.md | 6 ++++++ ipware/__init__.py | 2 +- ipware/ip.py | 7 +++++++ ipware/tests/tests_v1/tests_ipv4.py | 2 ++ ipware/tests/tests_v1/tests_ipv6.py | 2 ++ 8 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.travis.yml b/.travis.yml index d18bb7d..0f8f5df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ python: - "pypy3" env: - - DJANGO="django==2.0.4" - - DJANGO="django==1.11.12" + - DJANGO="django==2.1.3" + - DJANGO="django==1.11.16" install: - pip install $DJANGO @@ -27,10 +27,12 @@ before_script: matrix: exclude: - - python: "2.7" - env: DJANGO="django==2.0.4" - - python: "pypy" - env: DJANGO="django==2.0.4" + - python: "3.4" + env: DJANGO="django==2.1.3" + - python: "2.7" + env: DJANGO="django==2.1.3" + - python: "pypy" + env: DJANGO="django==2.1.3" script: coverage run --source=ipware manage.py test diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..625247d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.linting.enabled": false +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bb53c4b..9b32139 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.1.1 + +Enhancement: + - Added deprecation warnings preparing for version 3.0 + - Update to latest Django + ## 2.1.0 Enhancement: diff --git a/README.md b/README.md index b9a0e93..b414850 100644 --- a/README.md +++ b/README.md @@ -222,3 +222,9 @@ X.Y.Z Version [download-image]: https://img.shields.io/pypi/dm/django-ipware.svg [download-link]: https://pypi.python.org/pypi/django-ipware + + +Sponsors +==================== + +[![Surge](https://www.surgeforward.com/wp-content/themes/understrap-master/images/logo.png)](https://github.com/surgeforward) diff --git a/ipware/__init__.py b/ipware/__init__.py index a449aab..6d5b50e 100644 --- a/ipware/__init__.py +++ b/ipware/__init__.py @@ -5,4 +5,4 @@ __author__ = 'Val Neekman @ Neekware Inc. [@vneekman]' __description__ = "A Django application to retrieve user's IP address" -__version__ = '2.1.0' +__version__ = '2.1.1' diff --git a/ipware/ip.py b/ipware/ip.py index 97e6077..3efb491 100644 --- a/ipware/ip.py +++ b/ipware/ip.py @@ -1,3 +1,5 @@ +import warnings + from django.conf import settings from .utils import is_valid_ip @@ -6,6 +8,8 @@ NON_PUBLIC_IP_PREFIX = tuple([ip.lower() for ip in defs.IPWARE_NON_PUBLIC_IP_PREFIX]) TRUSTED_PROXY_LIST = tuple([ip.lower() for ip in getattr(settings, 'IPWARE_TRUSTED_PROXY_LIST', [])]) +warnings.simplefilter('always', DeprecationWarning) + def get_ip(request, real_ip_only=False, right_most_proxy=False): """ @@ -13,6 +17,7 @@ def get_ip(request, real_ip_only=False, right_most_proxy=False): @deprecated - Do not edit """ best_matched_ip = None + warnings.warn('get_ip is deprecated and will be removed in 3.0.', DeprecationWarning) for key in defs.IPWARE_META_PRECEDENCE_ORDER: value = request.META.get(key, request.META.get(key.replace('_', '-'), '')).strip() if value is not None and value != '': @@ -37,6 +42,7 @@ def get_real_ip(request, right_most_proxy=False): Returns client's best-matched `real` `externally-routable` ip-address, or None @deprecated - Do not edit """ + warnings.warn('get_real_ip is deprecated and will be removed in 3.0.', DeprecationWarning) return get_ip(request, real_ip_only=True, right_most_proxy=right_most_proxy) @@ -45,6 +51,7 @@ def get_trusted_ip(request, right_most_proxy=False, trusted_proxies=TRUSTED_PROX Returns client's ip-address from `trusted` proxy server(s) or None @deprecated - Do not edit """ + warnings.warn('get_trusted_ip is deprecated and will be removed in 3.0.', DeprecationWarning) if trusted_proxies: meta_keys = ['HTTP_X_FORWARDED_FOR', 'X_FORWARDED_FOR'] for key in meta_keys: diff --git a/ipware/tests/tests_v1/tests_ipv4.py b/ipware/tests/tests_v1/tests_ipv4.py index afe84c8..07f312a 100644 --- a/ipware/tests/tests_v1/tests_ipv4.py +++ b/ipware/tests/tests_v1/tests_ipv4.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import warnings from django.conf import settings from django.http import HttpRequest from django.test import TestCase @@ -7,6 +8,7 @@ from ipware.ip import get_real_ip from ipware.ip import get_trusted_ip +warnings.simplefilter('ignore') class IPv4TestCase(TestCase): """IP address Test""" diff --git a/ipware/tests/tests_v1/tests_ipv6.py b/ipware/tests/tests_v1/tests_ipv6.py index a73bcbb..10b4c82 100644 --- a/ipware/tests/tests_v1/tests_ipv6.py +++ b/ipware/tests/tests_v1/tests_ipv6.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import warnings from django.conf import settings from django.http import HttpRequest from django.test import TestCase @@ -8,6 +9,7 @@ from ipware.ip import get_real_ip from ipware.ip import get_trusted_ip +warnings.simplefilter('ignore') class IPv6TestCase(TestCase): """IP address Test"""