From 04c18b04ac50152be2c97c4cf52bcdaac5c301ba Mon Sep 17 00:00:00 2001 From: Andrei Lozhkin Date: Fri, 31 Oct 2025 16:36:50 +0700 Subject: [PATCH 1/4] refactor: replace pkg_resources-based Django version check Fixes /django_excel/_compact.py:1: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. --- django_excel/_compact.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/django_excel/_compact.py b/django_excel/_compact.py index 391578a..18c93c8 100644 --- a/django_excel/_compact.py +++ b/django_excel/_compact.py @@ -1,6 +1,6 @@ from distutils.version import LooseVersion -import pkg_resources +from django import get_version try: # if in py2 @@ -14,9 +14,9 @@ PY2_VERSION = False -django_version = pkg_resources.get_distribution("django").version +django_version = get_version() -DJANGO_ONE_SIX = LooseVersion(django_version) < LooseVersion( - "1.7.0" -) and LooseVersion(django_version) > LooseVersion("1.5.12") +DJANGO_ONE_SIX = LooseVersion(django_version) < LooseVersion("1.7.0") and LooseVersion( + django_version +) > LooseVersion("1.5.12") From e2240f54b8252e2172619fdee32fd36ced7bf2e4 Mon Sep 17 00:00:00 2001 From: Andrei Lozhkin Date: Fri, 31 Oct 2025 16:40:36 +0700 Subject: [PATCH 2/4] chore: exclude .venv from flake8 check --- lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lint.sh b/lint.sh index 3dc3aeb..d111fce 100644 --- a/lint.sh +++ b/lint.sh @@ -1,2 +1,2 @@ pip install flake8 -flake8 --exclude=.moban.d,docs,setup.py --ignore=F401,E402,E501,W503 --builtins=unicode,xrange,long . && python setup.py checkdocs \ No newline at end of file +flake8 --exclude=.venv,.moban.d,docs,setup.py --ignore=F401,E402,E501,W503 --builtins=unicode,xrange,long . && python setup.py checkdocs \ No newline at end of file From cc9d467567adab72d4194796348ee6e5c5d894ef Mon Sep 17 00:00:00 2001 From: Andrei Lozhkin Date: Fri, 31 Oct 2025 16:50:00 +0700 Subject: [PATCH 3/4] chore: update changelog.yml --- changelog.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/changelog.yml b/changelog.yml index 866177b..a4def89 100644 --- a/changelog.yml +++ b/changelog.yml @@ -1,6 +1,13 @@ name: django-excel organisation: pyexcel-webwares releases: +- changes: + - action: 'Change:' + details: + - Replace pkg_resources-based Django version check with django.get_version() + - Exclude .venv from flake8 check to simplify development + date: 31.10.2025 + version: 0.0.13 - changes: - action: 'Change:' details: From db2cedfb36c2e0a1f836c126b4870dbe360907c3 Mon Sep 17 00:00:00 2001 From: Andrei Lozhkin Date: Fri, 31 Oct 2025 16:50:27 +0700 Subject: [PATCH 4/4] chore: make format --- django_excel/__init__.py | 26 ++++++++++++++------------ django_excel/_compact.py | 6 +++--- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/django_excel/__init__.py b/django_excel/__init__.py index e2e7d15..eab088b 100644 --- a/django_excel/__init__.py +++ b/django_excel/__init__.py @@ -1,13 +1,14 @@ """ - django_excel - ~~~~~~~~~~~~~~~~~~~ +django_excel +~~~~~~~~~~~~~~~~~~~ - A django middleware that provides one application programming interface - to read and write data in different excel file formats +A django middleware that provides one application programming interface +to read and write data in different excel file formats - :copyright: (c) 2015 by Onni Software Ltd. - :license: New BSD License +:copyright: (c) 2015 by Onni Software Ltd. +:license: New BSD License """ + import pyexcel as pe import pyexcel_webio as webio from django.core.files.uploadedfile import ( @@ -174,11 +175,12 @@ def _make_response(content, content_type, status, file_name=None): if PY2_VERSION and isinstance(file_name, unicode): file_name = file_name.encode("utf-8") url_encoded_file_name = urllib_quote(file_name) - response[ - "Content-Disposition" - ] = "attachment; filename=%s;filename*=utf-8''%s" % ( - url_encoded_file_name, - url_encoded_file_name, + response["Content-Disposition"] = ( + "attachment; filename=%s;filename*=utf-8''%s" + % ( + url_encoded_file_name, + url_encoded_file_name, + ) ) return response @@ -186,9 +188,9 @@ def _make_response(content, content_type, status, file_name=None): webio.init_webio(_make_response) +from pyexcel_webio import make_response_from_array # noqa from pyexcel_webio import ( make_response, - make_response_from_array, # noqa make_response_from_book_dict, make_response_from_dict, make_response_from_query_sets, diff --git a/django_excel/_compact.py b/django_excel/_compact.py index 18c93c8..882307e 100644 --- a/django_excel/_compact.py +++ b/django_excel/_compact.py @@ -17,6 +17,6 @@ django_version = get_version() -DJANGO_ONE_SIX = LooseVersion(django_version) < LooseVersion("1.7.0") and LooseVersion( - django_version -) > LooseVersion("1.5.12") +DJANGO_ONE_SIX = LooseVersion(django_version) < LooseVersion( + "1.7.0" +) and LooseVersion(django_version) > LooseVersion("1.5.12")