From dc647834a1117a161b2551ea3fa1eb7b45480949 Mon Sep 17 00:00:00 2001 From: Val Neekman Date: Sun, 4 Feb 2024 14:24:57 -0500 Subject: [PATCH] Ci (#113) * Add types for get_client_ip parameters (#110) --------- Co-authored-by: Federico Bond --- .github/workflows/ci.yml | 4 ++-- CHANGELOG.md | 5 +++++ ipware/__version__.py | 2 +- ipware/ip.py | 15 +++++++++------ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8a13c1..339cfc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -52,6 +52,6 @@ jobs: - name: Run test run: coverage run --source=ipware manage.py test - name: Coveralls - run: coveralls --service=github + uses: coverallsapp/github-action@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index d1acb52..2468a4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 6.0.4 + +Enhancement: +- Add typings (thx: @federicobond) + # 6.0.3 Enhancement: diff --git a/ipware/__version__.py b/ipware/__version__.py index 30b3948..7a25cf8 100644 --- a/ipware/__version__.py +++ b/ipware/__version__.py @@ -5,4 +5,4 @@ __url__ = 'https://github.com/un33k/django-ipware' __license__ = 'MIT' __copyright__ = 'Copyright 2023 Val Neekman @ Neekware Inc.' -__version__ = '6.0.3' +__version__ = '6.0.4' diff --git a/ipware/ip.py b/ipware/ip.py index e8ae6d9..c64a3bd 100644 --- a/ipware/ip.py +++ b/ipware/ip.py @@ -1,14 +1,17 @@ +from typing import Iterable, Literal, Optional, Tuple + from django.conf import settings +from django.http import HttpRequest from python_ipware import IpWare def get_client_ip( - request, - proxy_order='left-most', - proxy_count=None, - proxy_trusted_ips=None, - request_header_order=None, -): + request: HttpRequest, + proxy_order: Literal['left-most', 'right-most'] = 'left-most', + proxy_count: Optional[int] = None, + proxy_trusted_ips: Optional[Iterable[str]] = None, + request_header_order: Optional[Iterable[str]] = None, +) -> Tuple[str, bool]: leftmost = proxy_order == 'left-most' proxy_count = proxy_count if proxy_count is not None else getattr(settings, 'IPWARE_META_PROXY_COUNT', 0) proxy_list = proxy_trusted_ips if proxy_trusted_ips is not None else []