Skip to content

Commit

Permalink
Merge pull request #612 from antonagestam/drop-legacy-versions
Browse files Browse the repository at this point in the history
Drop support for legacy versions
  • Loading branch information
benjaoming committed Sep 14, 2021
2 parents d17090e + fa30dcb commit eb64cad
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 82 deletions.
28 changes: 1 addition & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.9

- run: pip install tox

Expand All @@ -39,54 +39,28 @@ jobs:
strategy:
matrix:
include:
- python: pypy3
tox_env: django111-pypy3
- python: pypy3
tox_env: django21-pypy3
- python: pypy3
tox_env: django22-pypy3
- python: pypy3
tox_env: django30-pypy3
- python: pypy3
tox_env: django31-pypy3
- python: 3.5
tox_env: django111-py35
- python: 3.5
tox_env: django21-py35
- python: 3.5
tox_env: django22-py35
- python: 3.6
tox_env: django111-py36
- python: 3.6
tox_env: django21-py36
- python: 3.6
tox_env: django22-py36
- python: 3.6
tox_env: django30-py36
- python: 3.6
tox_env: django31-py36
- python: 3.6
tox_env: no_rest_framework
- python: 3.7
tox_env: django21-py37
- python: 3.7
tox_env: django22-py37
- python: 3.7
tox_env: django30-py37
- python: 3.7
tox_env: django31-py37
- python: 3.8
tox_env: django22-py38
- python: 3.8
tox_env: django30-py38
- python: 3.8
tox_env: django31-py38
- python: 3.8
tox_env: django_master-py38
- python: 3.9
tox_env: django22-py39
- python: 3.9
tox_env: django30-py39
- python: 3.9
tox_env: django31-py39
- python: 3.9
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
hooks:
- id: pyupgrade
args:
- --py3-plus
- --py36-plus

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ django-money
A little Django app that uses `py-moneyed <https://github.com/py-moneyed/py-moneyed>`__ to add support for Money
fields in your models and forms.

* Django versions supported: 1.11, 2.1, 2.2, 3.0, 3.1
* Python versions supported: 3.5, 3.6, 3.7, 3.8, 3.9
* Django versions supported: 2.2, 3.1, 3.2
* Python versions supported: 3.6, 3.7, 3.8, 3.9
* PyPy versions supported: PyPy3

If you need support for older versions of Django and Python, please refer to older releases mentioned in `the release notes <https://django-money.readthedocs.io/en/latest/changes.html>`__.
Expand Down
1 change: 1 addition & 0 deletions djmoney/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class MoneyConfig(AppConfig):
name = "djmoney"
default_auto_field = "django.db.models.AutoField"

def ready(self):
try:
Expand Down
6 changes: 3 additions & 3 deletions djmoney/contrib/exchange/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_rate(source, target, backend=None):
"""
if backend is None:
backend = get_default_backend_name()
key = "djmoney:get_rate:{}:{}:{}".format(source, target, backend)
key = f"djmoney:get_rate:{source}:{target}:{backend}"
result = cache.get(key)
if result is not None:
return result
Expand All @@ -57,7 +57,7 @@ def _get_rate(source, target, backend):
return 1
rates = Rate.objects.filter(currency__in=(source, target), backend=backend).select_related("backend")
if not rates:
raise MissingRate("Rate {} -> {} does not exist".format(source, target))
raise MissingRate(f"Rate {source} -> {target} does not exist")
if len(rates) == 1:
return _try_to_get_rate_directly(source, target, rates[0])
return _get_rate_via_base(rates, target)
Expand All @@ -74,7 +74,7 @@ def _try_to_get_rate_directly(source, target, rate):
elif rate.backend.base_currency == target and rate.currency == source:
return 1 / rate.value
# Case when target or source is not a base currency
raise MissingRate("Rate {} -> {} does not exist".format(source, target))
raise MissingRate(f"Rate {source} -> {target} does not exist")


def _get_rate_via_base(rates, target):
Expand Down
2 changes: 1 addition & 1 deletion djmoney/money.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def get_current_locale(for_babel=True):
if locale.upper() in moneyed.localization._FORMATTER.formatting_definitions:
return locale

locale = ("{}_{}".format(locale, locale)).upper()
locale = f"{locale}_{locale}".upper()
if locale in moneyed.localization._FORMATTER.formatting_definitions:
return locale

Expand Down
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
`Unreleased`_ - TBD
-------------------

- Drop support for Django 1.11, 2.1 and 3.0.
- Drop support for Python 3.5.
- Add support for Django 3.2.

`2.0.3`_ - 2021-09-04
---------------------

Expand Down
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,19 @@ def find_version():
setup(
name="django-money",
version=find_version(),
description="Adds support for using money and currency fields in django models and forms. "
"Uses py-moneyed as the money implementation.",
description=(
"Adds support for using money and currency fields in django models and forms. "
"Uses py-moneyed as the money implementation."
),
long_description=read("README.rst"),
long_description_content_type="text/x-rst",
url="https://github.com/django-money/django-money",
maintainer="Greg Reinbach",
maintainer_email="greg@reinbach.com",
license="BSD",
packages=find_packages(include=["djmoney", "djmoney.*"]),
install_requires=["setuptools", "Django>=1.11", "py-moneyed>=1.2,<2.0"],
python_requires=">=3.5",
install_requires=["setuptools", "Django>=2.2", "py-moneyed>=1.2,<2.0"],
python_requires=">=3.6",
platforms=["Any"],
keywords=["django", "py-money", "money"],
classifiers=[
Expand All @@ -74,14 +76,11 @@ def find_version():
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Framework :: Django",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.1",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
Expand Down
4 changes: 2 additions & 2 deletions tests/contrib/exchange/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ def test_rates_via_base(source, target, expected, django_assert_num_queries):
@pytest.mark.parametrize("source, target", (("NOK", "ZAR"), ("ZAR", "NOK"), ("USD", "ZAR"), ("ZAR", "USD")))
@pytest.mark.usefixtures("default_openexchange_rates")
def test_unknown_currency_with_partially_exiting_currencies(source, target):
with pytest.raises(MissingRate, match="Rate {} \\-\\> {} does not exist".format(source, target)):
with pytest.raises(MissingRate, match=f"Rate {source} \\-\\> {target} does not exist"):
get_rate(source, target)


@pytest.mark.parametrize("source, target", (("USD", "EUR"), ("SEK", "ZWL")))
def test_unknown_currency(source, target):
with pytest.raises(MissingRate, match="Rate {} \\-\\> {} does not exist".format(source, target)):
with pytest.raises(MissingRate, match=f"Rate {source} \\-\\> {target} does not exist"):
get_rate(source, target)


Expand Down
2 changes: 1 addition & 1 deletion tests/migrations/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def makemigrations():


def get_migration(name):
return __import__("money_app.migrations.{}_{}".format(name, MIGRATION_NAME), fromlist=["Migration"]).Migration
return __import__(f"money_app.migrations.{name}_{MIGRATION_NAME}", fromlist=["Migration"]).Migration


def get_operations(migration_name):
Expand Down
46 changes: 28 additions & 18 deletions tests/migrations/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ class Model(models.Model):
)
tests_path = os.path.dirname(os.path.dirname(tests.__file__))
return self.run(
"import sys; sys.path.append('{}');".format(tests_path)
+ "from tests.migrations.helpers import makemigrations; makemigrations();"
f"""
import sys
sys.path.append('{tests_path}')
from tests.migrations.helpers import makemigrations
makemigrations()
"""
)

def make_default_migration(self, field="MoneyField(max_digits=10, decimal_places=2, null=True)"):
Expand All @@ -77,31 +81,37 @@ def run(self, content):
return self.testdir.runpython_c(
dedent(
"""
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'app_settings'
from django import setup
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'app_settings'
from django import setup
setup()
%s
"""
% content
setup()
"""
)
+ dedent(content)
)

def create_instance(self):
self.run(
"""
from money_app.models import Model
from djmoney.money import Money
from money_app.models import Model
from djmoney.money import Money
Model.objects.create(field=Money(10, 'USD'))"""
Model.objects.create(field=Money(10, 'USD'))
"""
)

def migrate(self):
tests_path = os.path.dirname(os.path.dirname(tests.__file__))
return self.run(
"import sys; sys.path.append('{}');".format(tests_path)
+ "from tests.migrations.helpers import migrate; migrate();"
dedent(
f"""
import sys
sys.path.append('{tests_path}')
from tests.migrations.helpers import migrate
migrate()
"""
)
)

def assert_migrate(self, output=None):
Expand Down Expand Up @@ -200,11 +210,11 @@ def test_rename_field(self):
self.assert_migrate(["*Applying money_app.0002_test... OK*"])
result = self.run(
"""
from money_app.models import Model
from money_app.models import Model
instance = Model.objects.get()
print(instance.new_field)
"""
instance = Model.objects.get()
print(instance.new_field)
"""
)
result.stdout.fnmatch_lines(["$10.00"])

Expand Down
26 changes: 7 additions & 19 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[tox]
envlist =
django_master-py{39,38,37,36,py3}
django32-py{39,38,37,36,py3}
django31-py{39,38,37,36,py3}
django30-py{39,38,37,36,py3}
django22-py{39,38,37,36,py3}
django21-py{37,36,35,py3}
django111-py{36,35,py3}
lint
docs
skipsdist = true
Expand All @@ -17,11 +15,9 @@ python_paths = {toxinidir}
[testenv]
deps =
.[test,exchange]
django111: {[django]1.11.x}
django21: {[django]2.1.x}
django22: {[django]2.2.x}
django30: {[django]3.0.x}
django31: {[django]3.1.x}
django32: {[django]3.2.x}
django_master: {[django]master}
commands = py.test --ds=tests.settings_reversion --cov=./djmoney {posargs}
usedevelop = false
Expand All @@ -36,26 +32,18 @@ commands =
pre-commit run --all-files

[django]
1.11.x =
Django>=1.11.0,<2.0.0
django-reversion>=2.0.8,<3.0.8
djangorestframework>=3.6.2
2.1.x =
Django>=2.1,<2.2
django-reversion>=2.0.8
djangorestframework>=3.7.3
2.2.x =
Django>=2.2,<2.3
django-reversion>=2.0.8
djangorestframework>=3.7.3
3.0.x =
Django>=3.0,<3.1
django-reversion>=2.0.8
djangorestframework>=3.7.3
3.1.x =
Django>=3.1,<3.2
django-reversion>=3.0.8
djangorestframework>=3.12.0
3.2.x =
Django>=3.2,<3.3
django-reversion>=3.0.8
djangorestframework>=3.12.0
master =
https://github.com/django/django/tarball/main
djangorestframework>=3.12.0
Expand All @@ -67,7 +55,7 @@ deps =
django-reversion>=3.0.8

[testenv:docs]
basepython = python3.7
allowlist_externals = make
changedir = docs
deps =
sphinx
Expand Down

0 comments on commit eb64cad

Please sign in to comment.