Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chores] Updated CI configuration #49

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 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,7 @@ def readme():
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'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
17 changes: 10 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
[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}-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 +24,8 @@ 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
django42: django~=4.2.0
setenv =
noswap: DJANGO_SETTINGS_MODULE=tests.settings
swap: DJANGO_SETTINGS_MODULE=tests.swap_settings
Expand Down