From f728d8f455202c6ad3ebbc6171f142b99195d906 Mon Sep 17 00:00:00 2001 From: Alexey Semashkevich Date: Thu, 18 Jan 2024 13:40:20 +0100 Subject: [PATCH 1/4] Repair CI --- docs/conf.py | 2 +- tox.ini | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b5ca8c2..e7f97e0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -65,7 +65,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: diff --git a/tox.ini b/tox.ini index feb76df..d064fab 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,8 @@ envlist = usedevelop = True pip_pre = False extras = dev +setenv = + PYTHONPATH = {toxinidir} basepython = py37: python3.7 py38: python3.8 @@ -43,7 +45,7 @@ skip_install = True usedevelop = False changedir = docs/ deps = Sphinx -whitelist_externals = make +allowlist_externals = make commands = make clean html SPHINXOPTS='-W' python doc_checker.py @@ -60,6 +62,6 @@ commands = [testenv:docs] changedir = docs/ deps = Sphinx -whitelist_externals = make +allowlist_externals = make commands = make html From f6be50b036ed8f331a24ce885872c0a1e2ed18f4 Mon Sep 17 00:00:00 2001 From: Alexey Semashkevich Date: Thu, 18 Jan 2024 13:45:42 +0100 Subject: [PATCH 2/4] Update project documentation --- .travis.yml | 21 --------------------- README.rst | 4 ++-- agnocomplete/core.py | 4 ++-- docs/autocomplete-definition.rst | 4 ++-- docs/fields-widgets.rst | 2 +- docs/url-proxy.rst | 3 +-- 6 files changed, 8 insertions(+), 30 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6fb8923..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: python -dist: bionic -python: - - 3.6 - - 3.7 - - 3.8 - - 3.9 -install: - - pip install tox - - pip install -q tox-travis -script: - - tox - -stages: - - lint - - test - -jobs: - include: - - { stage: lint, env: TOXENV=flake8, python: 3.6 } - - { stage: lint, env: TOXENV=doclint, python: 3.6 } diff --git a/README.rst b/README.rst index 8a81d92..d5d573a 100644 --- a/README.rst +++ b/README.rst @@ -3,8 +3,8 @@ Django Agnostic Autocomplete ============================ -.. image:: https://travis-ci.org/peopledoc/django-agnocomplete.svg?branch=master - :target: https://travis-ci.org/peopledoc/django-agnocomplete +.. image:: https://github.com/peopledoc/django-agnocomplete/actions/workflows/ci.yml/badge.svg + :target: https://github.com/peopledoc/django-agnocomplete/actions/workflows/ci.yml Heavily based on `django-autocomplete-light v2 `_ workflow and concepts, this toolkit offers a front-end agnostic way to get fields for autocompletion. diff --git a/agnocomplete/core.py b/agnocomplete/core.py index 73712ba..a204416 100644 --- a/agnocomplete/core.py +++ b/agnocomplete/core.py @@ -59,13 +59,13 @@ def classproperty(func): e.g:: - class SafeClass(object): + class SafeClass: @classproperty def safe(cls): return True - class UnsafeClass(object): + class UnsafeClass: @classproperty def safe(cls): diff --git a/docs/autocomplete-definition.rst b/docs/autocomplete-definition.rst index cc62690..114ab2d 100644 --- a/docs/autocomplete-definition.rst +++ b/docs/autocomplete-definition.rst @@ -246,7 +246,7 @@ Your front-end code may send you extra arguments that are not covered by the sta extra = kwargs.get('extra_suff', None) if extra_stuff: change_something_in_the_search_method(extra_stuff) - return super(AutocompleteColorExtra, self).items(query, **kwargs) + return super().items(query, **kwargs) You can also override the :meth:`get_extra_arguments()` method **in your views** to eventually filter or manipulate these extra arguments. By default, :meth:`get_extra_arguments()` grabs arguments from the GET parameters that are not the `query` value. @@ -258,7 +258,7 @@ You can also override the :meth:`get_extra_arguments()` method **in your views** form = SearchFormExtra def get_extra_arguments(self): - extras = super(SelectizeExtraView, self).get_extra_arguments() + extras = super().get_extra_arguments() whitelist = ['foo', 'bar'] extras = filter(lambda x: x[0] in whitelist, extras) return dict(extras) diff --git a/docs/fields-widgets.rst b/docs/fields-widgets.rst index dd15524..a10b9bf 100644 --- a/docs/fields-widgets.rst +++ b/docs/fields-widgets.rst @@ -109,7 +109,7 @@ We're half way here: the view needs to know that, when the form & fields will be @method_decorator(allow_create) def form_valid(self, form): - return super(PersonTagModelViewWithCreate, self).form_valid(form) + return super().form_valid(form) .. important:: diff --git a/docs/url-proxy.rst b/docs/url-proxy.rst index 981677a..e545bfd 100644 --- a/docs/url-proxy.rst +++ b/docs/url-proxy.rst @@ -179,8 +179,7 @@ The :meth:`get_http_call_kwargs()` method is completely overridable like this: search_url = 'http://api.example.com/search' def get_http_call_kwargs(self, query, **kwargs): - query_args = super( - AutocompleteUrlExtraArgs, self).get_http_call_kwargs(query) + query_args = super().get_http_call_kwargs(query) query_args['auth_token'] = 'GOODAUTHTOKEN' return query_args From 029effaa09eba68bfc8d55bd440b342e6370114a Mon Sep 17 00:00:00 2001 From: Alexey Semashkevich Date: Thu, 18 Jan 2024 13:47:57 +0100 Subject: [PATCH 3/4] Drop obsolete code --- .github/workflows/ci.yml | 20 -------------------- README.rst | 8 ++++---- agnocomplete/__init__.py | 5 ----- demo/models.py | 18 ++++++------------ setup.cfg | 5 ----- tox.ini | 9 +-------- 6 files changed, 11 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e65e22..97602ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,22 +15,6 @@ jobs: matrix: include: - - name: Python 3.9 / Django 2.2 - python_version: "3.9" - tox_env: py39-django22 - - - name: Python 3.9 / Django 3.0 - python_version: "3.9" - tox_env: py39-django30 - - - name: Python 3.9 / Django 3.1 - python_version: "3.9" - tox_env: py39-django31 - - - name: Python 3.7 / Django 3.2 - python_version: "3.7" - tox_env: py37-django32 - - name: Python 3.8 / Django 3.2 python_version: "3.8" tox_env: py38-django32 @@ -43,10 +27,6 @@ jobs: python_version: "3.10" tox_env: py310-django32 - - name: Python 3.9 / Django 4.0 - python_version: "3.9" - tox_env: py39-django40 - - name: DocLint python_version: "3.10" tox_env: doclint diff --git a/README.rst b/README.rst index d5d573a..004da86 100644 --- a/README.rst +++ b/README.rst @@ -46,8 +46,8 @@ Install ``tox`` in your environment (it could be a virtualenv) and run: It'll run the tests for all the combinations of the following: -* Python 3.6, 3.7, 3.8, 3.9. -* Django 2.2. +* Python 3.8, 3.9. +* Django 3.2. and a ``flake8`` check. @@ -58,7 +58,7 @@ To target a specific test case, use the following: .. code:: sh - $ tox -e py37-django22 -- demo.tests.test_core.AutocompleteChoicesPagesOverrideTest + $ tox -e py38-django32 -- demo.tests.test_core.AutocompleteChoicesPagesOverrideTest Everything after the double-dash will be passed to the django-admin.py test command. @@ -66,7 +66,7 @@ If you need to install a debugger (let's say `ipdb`), you can use the ``TOX_EXTR .. code:: sh - $ TOX_EXTRA=ipdb tox -e py36-django22 + $ TOX_EXTRA=ipdb tox -e py38-django32 .. note:: diff --git a/agnocomplete/__init__.py b/agnocomplete/__init__.py index b07556b..21730ec 100644 --- a/agnocomplete/__init__.py +++ b/agnocomplete/__init__.py @@ -4,7 +4,6 @@ """ import logging -import django from django.conf import settings from django.utils.module_loading import autodiscover_modules @@ -24,7 +23,3 @@ def get_namespace(): def autodiscover(): """Auto-discover INSTALLED_APPS agnocomplete modules.""" autodiscover_modules('autocomplete') - - -if django.VERSION[:2] < (3, 2): - default_app_config = 'agnocomplete.apps.AgnocompleteConfig' diff --git a/demo/models.py b/demo/models.py index 8637d40..b59ba55 100644 --- a/demo/models.py +++ b/demo/models.py @@ -10,9 +10,8 @@ class Person(models.Model): email = models.EmailField(max_length=100) location = models.CharField(max_length=100) - def __unicode__(self): + def __str__(self): return " ".join((self.first_name, self.last_name)) - __str__ = __unicode__ @property def is_active(self): @@ -36,50 +35,45 @@ class FavoriteColor(models.Model): person = models.ForeignKey(Person, on_delete=models.CASCADE) color = models.CharField(max_length=100, choices=COLORS) - def __unicode__(self): + def __str__(self): return "{}'s favorite color is {}".format(self.person, self.color) - __str__ = __unicode__ class Tag(models.Model): name = models.CharField(max_length=50) - def __unicode__(self): + def __str__(self): return self.name - __str__ = __unicode__ class PersonTag(models.Model): person = models.ForeignKey(Person, on_delete=models.CASCADE) tags = models.ManyToManyField(Tag) - def __unicode__(self): + def __str__(self): return "{} is tagged: {}".format( self.person, ", ".join([force_str(t) for t in self.tags.all()]) or "Nothing" ) - __str__ = __unicode__ class ContextTag(models.Model): name = models.CharField(max_length=50) domain = models.CharField(max_length=100) - def __unicode__(self): + def __str__(self): return "[{}] {}".format( self.domain, self.name ) - __str__ = __unicode__ class PersonContextTag(models.Model): person = models.ForeignKey(Person, on_delete=models.CASCADE) tags = models.ManyToManyField(ContextTag) - def __unicode__(self): + def __str__(self): return "{} is tagged: {}".format( self.person, ", ".join([force_str(t) for t in self.tags.all()]) or "Nothing" ) - __str__ = __unicode__ diff --git a/setup.cfg b/setup.cfg index 99cce8e..3ac6034 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,15 +10,10 @@ classifiers = Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 - Framework :: Django :: 2.2 - Framework :: Django :: 3.0 - Framework :: Django :: 3.1 Framework :: Django :: 3.2 - Framework :: Django :: 4.0 Topic :: Internet :: WWW/HTTP Topic :: Internet :: WWW/HTTP :: Dynamic Content diff --git a/tox.ini b/tox.ini index d064fab..dec5ee3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,6 @@ [tox] envlist = - py39-django{22,30,31,40} - py{37,38,39,310}-django32, + py{38,39,310}-django32 flake8,doclint [testenv] @@ -11,7 +10,6 @@ extras = dev setenv = PYTHONPATH = {toxinidir} basepython = - py37: python3.7 py38: python3.8 py39: python3.9 py310: python3.10 @@ -22,12 +20,7 @@ deps = {env:TOX_EXTRA:} coverage -rrequirements-test.pip - # Keeping it here, because we'll probably widen our Django version tests. - django22: Django==2.2.* - django30: Django==3.0.* - django31: Django==3.1.* django32: Django==3.2.* - django40: Django==4.0.* serve: Django commands = pytest {posargs} From e106a11acae2edcbecc128f736c968cb8f3cf3d6 Mon Sep 17 00:00:00 2001 From: Alexey Semashkevich Date: Thu, 18 Jan 2024 13:50:36 +0100 Subject: [PATCH 4/4] Supports Django 4.2 --- .github/workflows/ci.yml | 16 ++++++++++++++++ README.rst | 4 ++-- setup.cfg | 6 +++--- tox.ini | 2 ++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97602ac..b4310ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,22 @@ jobs: python_version: "3.10" tox_env: py310-django32 + - name: Python 3.8 / Django 4.2 + python_version: "3.8" + tox_env: py38-django42 + + - name: Python 3.9 / Django 4.2 + python_version: "3.9" + tox_env: py39-django42 + + - name: Python 3.10 / Django 4.2 + python_version: "3.10" + tox_env: py310-django42 + + - name: Python 3.11 / Django 4.2 + python_version: "3.11" + tox_env: py311-django42 + - name: DocLint python_version: "3.10" tox_env: doclint diff --git a/README.rst b/README.rst index 004da86..40af149 100644 --- a/README.rst +++ b/README.rst @@ -46,8 +46,8 @@ Install ``tox`` in your environment (it could be a virtualenv) and run: It'll run the tests for all the combinations of the following: -* Python 3.8, 3.9. -* Django 3.2. +* Python 3.8, 3.9, 3.10 +* Django 3.2, 4.2 and a ``flake8`` check. diff --git a/setup.cfg b/setup.cfg index 3ac6034..98bf537 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,7 +13,9 @@ classifiers = Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Framework :: Django :: 3.2 + Framework :: Django :: 4.2 Topic :: Internet :: WWW/HTTP Topic :: Internet :: WWW/HTTP :: Dynamic Content @@ -47,8 +49,6 @@ addopts = testpaths = demo/tests/ filterwarnings = - error - # Ignoring for now: RemovedInDjango50Warning - ignore:.*The USE_L10N setting is deprecated.* + default DJANGO_SETTINGS_MODULE = demo.settings diff --git a/tox.ini b/tox.ini index dec5ee3..daadee9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,7 @@ [tox] envlist = py{38,39,310}-django32 + py{38,39,310,311}-django42 flake8,doclint [testenv] @@ -21,6 +22,7 @@ deps = coverage -rrequirements-test.pip django32: Django==3.2.* + django42: Django==4.2.* serve: Django commands = pytest {posargs}