From 19cc6af9098ee7e2c4b55acff93b6a075d121c1f Mon Sep 17 00:00:00 2001 From: abhiabhi94 <13880786+abhiabhi94@users.noreply.github.com> Date: Fri, 25 Jul 2025 13:29:20 +0530 Subject: [PATCH 1/3] chore: Move to pyproject.toml for modern packaging setuptools is deprecated and removed from python 3.13 --- MANIFEST.in | 9 ------ pyproject.toml | 75 ++++++++++++++++++++++++++++++++++++++++++++++++-- setup.cfg | 52 ---------------------------------- setup.py | 2 -- 4 files changed, 73 insertions(+), 65 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index a9bbdc8..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,9 +0,0 @@ -global-exclude *.py[cod] -include VERSION -include README -include pyproject.toml -recursive-include comment *.py -recursive-include comment/static * -recursive-include comment/templates * -recursive-include docs/source * -prune comment/tests diff --git a/pyproject.toml b/pyproject.toml index 9787c3b..b30fd5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,74 @@ [build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "django-comments-dab" +dynamic = ["version"] +description = "Django Comment app. It can be associated with any given model." +readme = "README.rst" +requires-python = ">=3.7" +license = "MIT" +keywords = ["django", "comment", "comments", "ajax"] +authors = [ + { name = "Radico", email = "mus.radi85@gmail.com" }, +] +maintainers = [ + { name = "Radi Mustafa", email = "mus.radi85@gmail.com" }, +] +classifiers = [ + "Environment :: Web Environment", + "Framework :: Django", + "Framework :: Django :: 2.2", + "Framework :: Django :: 3.0", + "Framework :: Django :: 3.1", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.0", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: Dynamic Content", +] +dependencies = [ + "django", +] + +[project.optional-dependencies] +markdown = ["markdown"] + +[project.urls] +Homepage = "https://github.com/radi85/Comment" +Documentation = "https://django-comment-dab.readthedocs.io/index.html" +"Source Code" = "https://github.com/radi85/Comment" + +[tool.hatch.version] +path = "VERSION" +pattern = "(?P.*)" + +[tool.hatch.build.targets.wheel] +packages = ["comment"] +include = [ + "comment/static/**/*", + "comment/templates/**/*", + "comment/locale/**/*", +] + +[tool.hatch.build.targets.sdist] +include = [ + "/comment", + "/VERSION", + "/README.rst", + "/LICENSE", + "/pyproject.toml", +] +exclude = [ + "*.py[cod]", + "__pycache__", + "/comment/tests", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a313083..0000000 --- a/setup.cfg +++ /dev/null @@ -1,52 +0,0 @@ -[metadata] -name = django-comments-dab -version = file: VERSION -author = Radico -author_email = mus.radi85@gmail.com -description = Django Comment app. It can be associated with any given model. -long_description = file: README.rst -long_description_content_type = text/x-rst -maintainer = Radi Mustafa -maintainer_email = mus.radi85@gmail.com -url = https://github.com/radi85/Comment -project_urls = - Documentation=https://django-comment-dab.readthedocs.io/index.html - Source Code=https://github.com/radi85/Comment -license = MIT -classifiers = - Environment :: Web Environment - Framework :: Django - Framework :: Django :: 2.2 - Framework :: Django :: 3.0 - Framework :: Django :: 3.1 - Framework :: Django :: 3.2 - Framework :: Django :: 4.0 - Intended Audience :: Developers - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Topic :: Internet :: WWW/HTTP - Topic :: Internet :: WWW/HTTP :: Dynamic Content -keywords = django comment comments ajax - -[options] -packages = find: -include_package_data = True -install_requires = django -zip_safe = False - -[options.extras_require] -markdown = markdown - -[options.packages.find] -exclude = - docs - test* - -[flake8] -exclude = .git,*migrations*,test -max-line-length = 120 diff --git a/setup.py b/setup.py deleted file mode 100644 index 8bf1ba9..0000000 --- a/setup.py +++ /dev/null @@ -1,2 +0,0 @@ -from setuptools import setup -setup() From 8dd6da90672a957e0f6d07740652521f326518fb Mon Sep 17 00:00:00 2001 From: abhiabhi94 <13880786+abhiabhi94@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:53:11 +0530 Subject: [PATCH 2/3] Fix docs build - read the docs now requires a separate file to build --- .readthedocs.yaml | 35 +++++++++++++++++++++++++++++++++++ docs/source/conf.py | 1 + docs/source/requirements.txt | 4 +++- tox.ini | 1 - 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..38489fe --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,35 @@ +# Read the Docs configuration file for Sphinx projects +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the OS, Python version and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.13" + # You can also specify other tool versions: + # nodejs: "20" + # rust: "1.70" + # golang: "1.20" + +# Build documentation in the "docs/" directory with Sphinx +sphinx: + configuration: docs/conf.py + # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs + # builder: "dirhtml" + # Fail on all warnings to avoid broken references + # fail_on_warning: true + +# Optionally build your docs in additional formats such as PDF and ePub +# formats: +# - pdf +# - epub + +# Optional but recommended, declare the Python requirements required +# to build your documentation +# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +python: + install: + - requirements: docs/source/requirements.txt diff --git a/docs/source/conf.py b/docs/source/conf.py index 669251c..7045d35 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -53,6 +53,7 @@ def get_version(): 'sphinx.ext.githubpages', 'sphinx.ext.autosectionlabel', 'sphinxcontrib.swagger', + 'sphinx_rtd_theme', ] openapi = { diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt index 09c2115..49421b7 100644 --- a/docs/source/requirements.txt +++ b/docs/source/requirements.txt @@ -1 +1,3 @@ -sphinxcontrib-swagger>=0.0.2 +setuptools # sphninxcontrib-swagger requires setuptools +sphinxcontrib-swagger +sphinx_rtd_theme diff --git a/tox.ini b/tox.ini index 142cc30..ffc88ac 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,6 @@ allowlist_externals = deps = -rdocs/source/requirements.txt Sphinx - sphinx_rtd_theme changedir = docs commands = make html From 586e1297e12eeb6a55b25cc914520e91bcbc9503 Mon Sep 17 00:00:00 2001 From: abhiabhi94 <13880786+abhiabhi94@users.noreply.github.com> Date: Fri, 25 Jul 2025 15:40:36 +0530 Subject: [PATCH 3/3] feat: Add support for Django 4.2-5.2 and Python 3.10-3.13 - update supported Django versions from 2.2-3.2 to 4.2-5.2 - update supported Python versions from 3.6-3.10 to 3.10-3.13 - drop support for Django and Python versions that have reached end of life. - remove deprecated Django features and compatibility code --- .github/workflows/docs.yml | 8 +++--- .github/workflows/linters.yml | 6 ++-- .github/workflows/release.yml | 6 ++-- .github/workflows/test-release.yml | 6 ++-- .github/workflows/tests.yml | 23 +++++++++------- comment/__init__.py | 5 ---- comment/api/serializers.py | 4 +-- comment/conf/__init__.py | 8 ++---- comment/tests/base.py | 4 +-- comment/tests/test_forms.py | 9 ++++-- comment/tests/test_models/test_comments.py | 4 +-- docs/source/Changelog.rst | 7 +++++ pyproject.toml | 17 ++++++------ setup.cfg | 3 ++ tox.ini | 32 ++++++++++++---------- 15 files changed, 76 insertions(+), 66 deletions(-) create mode 100644 setup.cfg diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index db090b8..f72712b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,15 +17,15 @@ jobs: name: docs steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.13' - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('docs/source/requirements.txt') }} diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 04f1863..ec59f7d 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -13,12 +13,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.13' - name: Ensure latest setuptools run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0dd9b8b..b7e75e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,10 +13,10 @@ jobs: - name: Checkout uses: actions/checkout@master - - name: Set up Python 3.9 - uses: actions/setup-python@v1 + - name: Set up Python + uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.13' - name: Ensure latest setuptools run: python -m pip install --upgrade pip setuptools wheel diff --git a/.github/workflows/test-release.yml b/.github/workflows/test-release.yml index 64857fb..d593100 100644 --- a/.github/workflows/test-release.yml +++ b/.github/workflows/test-release.yml @@ -13,10 +13,10 @@ jobs: - name: Checkout uses: actions/checkout@master - - name: Set up Python 3.9 - uses: actions/setup-python@v1 + - name: Set up Python 3 + uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.13' - name: Ensure latest setuptools run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 20579f3..37d48db 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,22 +17,22 @@ jobs: max-parallel: 5 matrix: python-version: - - 3.7 - - 3.8 - - 3.9 - '3.10' + - '3.11' + - '3.12' + - '3.13' steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('test/example/requirements.txt') }} @@ -42,14 +42,17 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade tox tox-py codecov + python -m pip install --upgrade tox tox-py coverage codecov-cli sudo apt-get install gettext - name: Run tox targets for ${{ matrix.python-version }} run: | tox --py current + coverage combine + coverage xml -o coverage.xml - name: Coverage reporting - run: | - coverage combine - codecov + uses: codecov/codecov-action@v5 + with: + fail_ci_if_error: true + verbose: true diff --git a/comment/__init__.py b/comment/__init__.py index cb736eb..4a167b3 100644 --- a/comment/__init__.py +++ b/comment/__init__.py @@ -1,5 +1,4 @@ import os -import django __version__ = '2.8.0' @@ -22,7 +21,3 @@ def check_release(): check_release() - - -if django.VERSION < (3, 2): - default_app_config = 'comment.apps.CommentConfig' diff --git a/comment/api/serializers.py b/comment/api/serializers.py index 35ca7c8..bb4bd2d 100644 --- a/comment/api/serializers.py +++ b/comment/api/serializers.py @@ -69,14 +69,14 @@ def get_parent(obj): @staticmethod def get_replies(obj): - if obj.is_parent: + if obj.pk and obj.is_parent: return CommentSerializer(obj.replies(), many=True).data else: return [] @staticmethod def get_reply_count(obj): - if obj.is_parent: + if obj.pk and obj.is_parent: return obj.replies().count() else: return 0 diff --git a/comment/conf/__init__.py b/comment/conf/__init__.py index 874115e..43991b0 100644 --- a/comment/conf/__init__.py +++ b/comment/conf/__init__.py @@ -7,11 +7,9 @@ _django_version = django.VERSION DEPRECATED_SETTINGS = { - 'PASSWORD_RESET_TIMEOUT_DAYS' if _django_version > (3, 0) else None, - 'DEFAULT_CONTENT_TYPE' if _django_version > (2, 2) else None, - 'FILE_CHARSET' if _django_version > (2, 2) else None, - 'USE_L10N' if _django_version > (4, 0) else None, - 'USE_TZ' if _django_version > (4, 0) else None, + 'DEFAULT_FILE_STORAGE' if (4, 2) <= _django_version < (5, 1) else None, + 'STATICFILES_STORAGE' if (4, 2) <= _django_version < (5, 1) else None, + 'USE_L10N' if (4, 0) <= _django_version < (5, 0) else None, } diff --git a/comment/tests/base.py b/comment/tests/base.py index aecc5c5..f8a1bdc 100644 --- a/comment/tests/base.py +++ b/comment/tests/base.py @@ -213,11 +213,11 @@ def assertTextTranslated(self, text, url=None): f'No translation for the text "{text}" from view {self.get_view_from_url_or_none(url)}' ) - def assertQuerysetEqual(self, qs, values, transform=None, ordered=True, msg=None): + def assertQuerySetEqual(self, qs, values, transform=None, ordered=True, msg=None): if not transform: def transform(x): return x - return super().assertQuerysetEqual(qs, values, transform=transform, ordered=True, msg=msg) + return super().assertQuerySetEqual(qs, values, transform=transform, ordered=True, msg=msg) def assert_permission_denied_response(self, response, reason=None): forbidden_code = 403 diff --git a/comment/tests/test_forms.py b/comment/tests/test_forms.py index 71c8f15..4bdc3d3 100644 --- a/comment/tests/test_forms.py +++ b/comment/tests/test_forms.py @@ -32,10 +32,13 @@ def test_create_anonymous_comment_form(self): self.assertEqual(email_field.label, EmailInfo.LABEL) self.assertTextTranslated(email_field.label) self.assertEqual(email_field.widget.input_type, field) - self.assertDictEqual(email_field.widget.attrs, { + expected_attrs = { 'placeholder': EmailInfo.INPUT_PLACEHOLDER, - 'title': EmailInfo.INPUT_TITLE - }) + 'title': EmailInfo.INPUT_TITLE, + 'maxlength': email_field.widget.attrs['maxlength'] + } + + self.assertDictEqual(email_field.widget.attrs, expected_attrs) @patch.object(settings, 'COMMENT_ALLOW_ANONYMOUS', True) def test_create_anonymous_comment_without_email(self): diff --git a/comment/tests/test_models/test_comments.py b/comment/tests/test_models/test_comments.py index a98d4be..2119fd9 100644 --- a/comment/tests/test_models/test_comments.py +++ b/comment/tests/test_models/test_comments.py @@ -255,14 +255,14 @@ def setUp(self): self.all_comments_qs = Comment.objects.all_exclude_flagged() def test_default_value(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Comment.objects._filter_parents(self.all_comments_qs), self.all_parents_qs.order_by(*settings.COMMENT_ORDER_BY) ) @patch.object(settings, 'COMMENT_ORDER_BY', ['-reaction__likes']) def test_custom_values(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Comment.objects._filter_parents(self.all_comments_qs), self.all_parents_qs.order_by(*settings.COMMENT_ORDER_BY) ) diff --git a/docs/source/Changelog.rst b/docs/source/Changelog.rst index 66f75bc..ef5208d 100644 --- a/docs/source/Changelog.rst +++ b/docs/source/Changelog.rst @@ -1,5 +1,12 @@ Changelog ========= +3.0.0 +------ +- Confirm support for Python ``3.11``, ``3.12``, ``3.13``. +- Confirm support for Django ``4.2``, ``5.0``, ``5.1``, ``5.2``. +- Remove support for Python ``3.6``, ``3.7``, ``3.8``, ``3.9``. +- Remove support for Django ``3.2``, ``4.0``. + 2.8.0 ------ diff --git a/pyproject.toml b/pyproject.toml index b30fd5b..c393e8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "django-comments-dab" dynamic = ["version"] description = "Django Comment app. It can be associated with any given model." readme = "README.rst" -requires-python = ">=3.7" +requires-python = ">=3.10" license = "MIT" keywords = ["django", "comment", "comments", "ajax"] authors = [ @@ -19,19 +19,18 @@ maintainers = [ classifiers = [ "Environment :: Web Environment", "Framework :: Django", - "Framework :: Django :: 2.2", - "Framework :: Django :: 3.0", - "Framework :: Django :: 3.1", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.0", + "Framework :: Django :: 4.2", + "Framework :: Django :: 5.0", + "Framework :: Django :: 5.1", + "Framework :: Django :: 5.2", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", ] diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..f83ba84 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[flake8] +exclude = .git,*migrations*,test +max-line-length = 120 diff --git a/tox.ini b/tox.ini index ffc88ac..dd73c5c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,16 @@ [tox] envlist = - py37-django{22, 30, 31, 32} - py38-django{22, 30, 31, 32, 40, main} - py39-django{22, 30, 31, 32, 40, main} - py310-django{40, main} + py310-django{42, 50, 51, 52} + py311-django{42, 50, 51, 52} + py312-django{42, 50, 51, 52, main} + py313-django{42, 50, 51, 52, main} [gh-actions] python = - 3.7: py37 - 3.8: py38 - 3.9: py39 3.10: py310 + 3.11: py311 + 3.12: py312 + 3.13: py313 [testenv:docs] allowlist_externals = @@ -35,11 +35,10 @@ deps = lxml beautifulsoup4 cssselect - django22: Django>=2.2,<2.3 - django30: Django>=3.0,<3.1 - django31: Django>=3.1,<3.2 - django32: Django>=3.2,<4.0 - django40: Django>=4.0,<4.1 + django42: Django>=4.2,<4.3 + django50: Django>=5.0,<5.1 + django51: Django>=5.1,<5.2 + django52: Django>=5.2,<5.3 djangomain: https://github.com/django/django/archive/main.tar.gz extras = @@ -55,11 +54,14 @@ setenv = PYTHONDONTWRITEBYTECODE=1 DJANGO_SETTINGS_MODULE=test.settings.test -[testenv:py38-djangomain] +[testenv:py310-djangomain] ignore_outcome = true -[testenv:py39-djangomain] +[testenv:py311-djangomain] ignore_outcome = true -[testenv:py310-djangomain] +[testenv:py312-djangomain] +ignore_outcome = true + +[testenv:py313-djangomain] ignore_outcome = true