Skip to content

Commit

Permalink
[chores] Updated CI configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy committed Aug 13, 2024
1 parent dcd67a2 commit 0be7c01
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
- "3.11"

steps:
- uses: actions/checkout@v4
Expand Down
22 changes: 14 additions & 8 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ Changelog
Verson 1.3.0 [2021-11-29]
-------------------------

- [change] Allow possibility to point swappable dependency to specific migration number
(instead of only to ``__latest__``)
- [change] Allow possibility to point swappable dependency to specific
migration number (instead of only to ``__latest__``)

Version 1.2.0 [2021-11-12]
--------------------------

- [feature] Add possibility to point swappable dependency to ``__latest__``
- [feature] Add possibility to point swappable dependency to
``__latest__``
- [change] Added support for Python 3.9
- [change] Added support for Django 3.2 and Django 4.0a1
- [change] Dropped support for old Django versions (<2.2)
- [change] Dropped support for old Python versions (<3.7)
- [feature] Added optional ``require_ready`` argument to ``load_model`` function
- [feature] Added optional ``require_ready`` argument to ``load_model``
function

Version 1.1.2 [2020-01-15]
--------------------------
Expand All @@ -34,27 +36,31 @@ Version 1.1.0 [2017-05-11]
--------------------------

- [test] Added tests for swapper.split
- `#13 <https://github.com/openwisp/django-swappable-models/pull/13>`_ [fix] Handle contrib apps and apps with dot in app_label.
- `#13 <https://github.com/openwisp/django-swappable-models/pull/13>`_
[fix] Handle contrib apps and apps with dot in app_label.

Version 1.0.0 [2016-08-26]
--------------------------

- [docs] Improved usuability docs
- `86e238 <https://github.com/openwisp/django-swappable-models/commit/86e238>`_:
- `86e238
<https://github.com/openwisp/django-swappable-models/commit/86e238>`_:
[deps] Compatibility with django 1.10 added

Version 0.3.0 [2015-11-17]
--------------------------

- `#9 <https://github.com/openwisp/django-swappable-models/pull/9>`_ [deps] Added support for django 1.9
- `#9 <https://github.com/openwisp/django-swappable-models/pull/9>`_
[deps] Added support for django 1.9

Version 0.2.2 [2015-06-16]
--------------------------

- [deps] Added support for django~=1.6.0
- [deps] Added support for Python 3.3
- [docs] Fix model reference in README
- [docs] Notes for load_model initialization (`for more info see #2 <https://github.com/openwisp/django-swappable-models/issues/2>`_)
- [docs] Notes for load_model initialization (`for more info see #2
<https://github.com/openwisp/django-swappable-models/issues/2>`_)

Version 0.2.1 [2014-11-18]
--------------------------
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def readme():
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'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',
'Framework :: Django',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
Expand All @@ -43,6 +44,8 @@ def readme():
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
],
tests_require=['django>=2.0'],
test_suite='tests',
Expand Down
31 changes: 15 additions & 16 deletions swapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@


def swappable_setting(app_label, model):
"""
Returns the setting name to use for the given model (i.e. AUTH_USER_MODEL)
"""Returns the setting name to use for the given model
Returns the setting name to use for the given model (i.e.
AUTH_USER_MODEL)
"""
prefix = _prefixes.get(app_label, app_label)
setting = "{prefix}_{model}_MODEL".format(
Expand All @@ -23,7 +25,8 @@ def swappable_setting(app_label, model):


def is_swapped(app_label, model):
"""
"""Returns the value of the swapped setting.
Returns the value of the swapped setting, or False if the model hasn't
been swapped.
"""
Expand All @@ -37,15 +40,17 @@ def is_swapped(app_label, model):


def get_model_name(app_label, model):
"""
Returns [app_label.model] unless the model has been swapped, in which case
returns the swappable setting value.
"""Returns [app_label.model].
Returns [app_label.model] unless the model has been swapped, in which
case returns the swappable setting value.
"""
return is_swapped(app_label, model) or join(app_label, model)


def dependency(app_label, model, version=None):
"""
"""Returns a Django 1.7+ style dependency tuple
Returns a Django 1.7+ style dependency tuple for inclusion in
migration.dependencies[]
"""
Expand All @@ -56,16 +61,12 @@ def dependency(app_label, model, version=None):


def get_model_names(app_label, models):
"""
Map model names to their swapped equivalents for the given app
"""
"""Map model names to their swapped equivalents for the given app"""
return dict((model, get_model_name(app_label, model)) for model in models)


def load_model(app_label, model, required=True, require_ready=True):
"""
Load the specified model class, or the class it was swapped out for.
"""
"""Load the specified model class, or the class it was swapped out for."""
swapped = is_swapped(app_label, model)
if swapped:
app_label, model = split(swapped)
Expand All @@ -83,9 +84,7 @@ def load_model(app_label, model, required=True, require_ready=True):


def set_app_prefix(app_label, prefix):
"""
Set a custom prefix to use for the given app (e.g. WQ)
"""
"""Set a custom prefix to use for the given app (e.g. WQ)"""
_prefixes[app_label] = prefix


Expand Down
1 change: 0 additions & 1 deletion tests/test_swapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class SwapperTestCase(TestCase):

# Tests that should work whether or not default_app.Type is swapped
def test_fields(self):
Type = swapper.load_model('default_app', 'Type')
Expand Down
19 changes: 12 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
[tox]
envlist =
py{37,38}-django22-{noswap,swap}
py{37,38}-django30-{noswap,swap}
py{37,38,39}-django31-{noswap,swap}
py{37,38,39}-django32-{noswap,swap}
py{38,39}-django40-{noswap, swap}
py{38}-django22-{noswap,swap}
py{38}-django30-{noswap,swap}
py{38,39}-django31-{noswap,swap}
py{38,39,310}-django32-{noswap,swap}
py{38,39,310}-django40-{noswap, swap}
py{38,39,310,311}-django41-{noswap, swap}
py{38,39,310,311}-django42-{noswap, swap}
lint

[gh-actions]
python =
3.7: py37
3.8: py38, lint
3.9: py39, lint
3.10: py310, lint
3.11: py311, lint

[testenv]
commands =
Expand All @@ -22,7 +25,9 @@ deps =
django30: django~=3.0.0
django31: django~=3.1.0
django32: django~=3.2.0
django40: django~=4.0a1
django40: django~=4.0.0
django41: django~=4.1.0
django42: django~=4.2.0
setenv =
noswap: DJANGO_SETTINGS_MODULE=tests.settings
swap: DJANGO_SETTINGS_MODULE=tests.swap_settings
Expand Down

0 comments on commit 0be7c01

Please sign in to comment.