Skip to content

Commit a4e4e14

Browse files
committed
chore: Added support for Django 5, switched to ruff.
Reformatted using ruff defaults, so single quotes were replaced with double quotes. Dropped Python 3.7, 3.8, and Django 2 from tox tests.
1 parent 1eb0a0b commit a4e4e14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+787
-1344
lines changed

.github/workflows/tox.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
14-
django-version: [ ">=2.2,<3", ">=3,<4", ">=4,<5" ]
15-
exclude:
16-
- python-version: 3.7
17-
django-version: ">=4,<5"
13+
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
14+
django-version: [ ">=3,<4", ">=4,<5", ">=5,<6" ]
1815

1916
steps:
2017
#----------------------------------------------

.python-version

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
3.7.12
2-
3.8.10
3-
3.9.6
4-
3.10.1
1+
3.9
2+
3.10
3+
3.11
4+
3.12

.travis.yml

-18
This file was deleted.

CHANGELOG.md

+68-8
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,165 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
56
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
67

8+
## [2.2.0]
9+
10+
### Added
11+
12+
- Added support for Django 5
13+
14+
### Changed
15+
16+
- Dropped Python 3.7, 3.8, and Django 2 from tox tests. They should still work however.
17+
718
## [2.1.0]
19+
820
### Added
21+
922
- Added search_fields to CountryAdmin, thanks DanyPM
23+
1024
## [2.0.1]
25+
1126
### Fixed
27+
1228
- Replaced deprecated ugettext with gettext, supported in Django 2.2, 3, & 4, thanks to @niSeRdiSeR
1329
- Updated tox config
1430
- Django 4, python 3.10 test added to matrix
1531

1632
## [2.0.0]
33+
1734
### Changed
35+
1836
- Dropped support for Python 2 and Django 1
1937

2038
## [1.3.2]
39+
2140
### Fixed
41+
2242
- Fixed update_countries_plus, thanks to @jeyeong and @buff0k
2343

2444
## [1.3.1]
45+
2546
### Fixed
47+
2648
- Restored support for Django 1.11+
2749

2850
## [1.3.0] - 2020-01-20
51+
2952
### Changed
53+
3054
- Updated to use poetry & pytest
3155
- Added tests for Django 3
3256
- Dropped explicit support for Django <=1.10, may still work fine though.
3357

3458
## [1.2.1] - 2017-12-13
59+
3560
### Fixed
61+
3662
- Fixtures dir is now properly included in pip package
3763

3864
## [1.2.0] - 2017-12-13
65+
3966
### Added
67+
4068
- Cleaned up project & improved documentation
4169

4270
### Changed
71+
4372
- Added tests for Django 2.0
4473
- Dropped tested support for Django versions < 1.11
4574

4675
## [1.1.0] - 2016-03-14
76+
4777
### Fixed
78+
4879
- Fixed Geonames.org file format error
4980

5081
## [1.0.1] - 2015-06-16
82+
5183
### Added
84+
5285
- Improved test coverage.
5386

5487
### Changed
55-
- The Country model has had all fields with undefined lengths (ex: name) expanded to max_length=255. Defined length fields (ex: Iso, Iso3) are unchanged.
56-
- Two countries (Dominican Republic and Puerto Rico) have two phone number prefixes instead of 1. These prefixes are now comma separated.
57-
- The Country model will now validate on save and reject values of the wrong length. The test suite has been expanded to test this.
88+
89+
- The Country model has had all fields with undefined lengths (ex: name) expanded to max_length=255. Defined length
90+
fields (ex: Iso, Iso3) are unchanged.
91+
- Two countries (Dominican Republic and Puerto Rico) have two phone number prefixes instead of 1. These prefixes are now
92+
comma separated.
93+
- The Country model will now validate on save and reject values of the wrong length. The test suite has been expanded to
94+
test this.
5895

5996
### Fixed
97+
6098
- Fixed update_countries_plus command for python 3
6199

62100
## [1.0.0] - 2015-06-11
101+
63102
### Added
64-
- Added feature to update data from geonames.org.
103+
104+
- Added feature to update data from geonames.org.
65105
- Test coverage has been substantially improved.
66106

67107
### Changed
108+
68109
- The data migration has been removed in favour of the new management command and manually loading the fixture.
69110
- The fixture is no longer named initial_data and so must be loaded manually, if desired.
70-
- In order to provide better compatibility with the way Django loads apps the Country model is no longer importable directly from countries_plus.
71-
- The get_country_by_request utility function has been moved into the Country model, and is available as Country.get_by_request(request)
111+
- In order to provide better compatibility with the way Django loads apps the Country model is no longer importable
112+
directly from countries_plus.
113+
- The get_country_by_request utility function has been moved into the Country model, and is available as
114+
Country.get_by_request(request)
115+
116+
### Fixed
72117

73-
### Fixed
74118
- General code cleanup & improved test coverage.
75119

76120
### Note
77-
- If you have been running an earlier version you should run python manage.py update_countries_plus to update your data tables as they may contain incorrect data.
121+
122+
- If you have been running an earlier version you should run python manage.py update_countries_plus to update your data
123+
tables as they may contain incorrect data.
78124

79125
## [0.3.3] - 2015-01-27
126+
80127
### Changed
128+
81129
- Now uses Django 1.7 data migration pattern
82130

83131
## [0.3.2] - 2015-01-10
132+
84133
### Fixed
134+
85135
- Corrected version number on setup.py
86136

87137
## [0.3.1] - 2015-01-09
138+
88139
### Added
140+
89141
- Now compatible with Python 3 thanks to luiscberrocal
90142

91143
## [0.3.0] - 2014-09-08
144+
92145
### Added
146+
93147
- Now compatible with Django 1.7 thanks to mrben
94148

95149
## [0.2.0] - 2014-02-13
150+
96151
### Added
152+
97153
- Added middleware that adds the request country to the request object.
98154

99155
## [0.1.5] - 2013-06-14
156+
100157
### Fixed
158+
101159
- Corrected model max_length attributes to properly match data.
102160

103161
## [0.1.0] - 2013-05-22
162+
104163
### Added
164+
105165
- Initial release.

CONTRIBUTING.rst

+7-14
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ Ready to contribute? Here's how to set up `django-countries-plus` for local deve
7474

7575
Now you can make your changes locally.
7676

77-
5. When you're done making changes, check that your changes pass flake8 and the
78-
tests, including testing other Python versions with tox::
77+
5. When you're done making changes, check that your changes are lint free, formatted, and pass the tests,
78+
including testing other Python versions with tox::
7979

80-
$ flake8 countries_plus tests
81-
$ python setup.py test
80+
$ ruff check .
81+
# ruff format
8282
$ tox
8383

8484
To get flake8 and tox, just pip install them into your virtualenv.
@@ -100,13 +100,6 @@ Before you submit a pull request, check that it meets these guidelines:
100100
2. If the pull request adds functionality, the docs should be updated. Put
101101
your new functionality into a function with a docstring, and add the
102102
feature to the list in README.rst.
103-
3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check
104-
https://travis-ci.org/cordery/django-countries-plus/pull_requests
105-
and make sure that the tests pass for all supported Python versions.
106-
107-
Tips
108-
----
109-
110-
To run a subset of tests::
111-
112-
$ python -m unittest tests.test_countries_plus
103+
3. The pull request should work for the Python & Django versions specified in
104+
tox.ini. Run tox and make sure that the tests pass for all supported Python
105+
versions.

README.rst

+2-10
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,9 @@ Django Countries Plus
55
.. image:: https://badge.fury.io/py/django-countries-plus.svg
66
:target: https://badge.fury.io/py/django-countries-plus
77

8-
.. image:: https://travis-ci.org/cordery/django-countries-plus.svg
9-
:target: https://travis-ci.org/cordery/django-countries-plus
8+
.. image:: https://github.com/cordery/django-countries-plus/actions/workflows/tox.yml/badge.svg
9+
:target: https://github.com/cordery/django-countries-plus/actions/workflows/tox.yml
1010

11-
.. image:: https://codecov.io/github/cordery/django-countries-plus/coverage.svg
12-
:target: https://codecov.io/github/cordery/django-countries-plus
13-
14-
.. image:: https://requires.io/github/cordery/django-countries-plus/requirements.svg?branch=master
15-
:target: https://requires.io/github/cordery/django-countries-plus/requirements/?branch=master
16-
17-
.. image:: https://www.codacy.com/project/badge/c74f1b1041f44940b58e0e1587b10453?style=flat-square
18-
:target: https://www.codacy.com/app/cordery/django-countries-plus
1911

2012
django-countries-plus provides a model and fixture containing all top level country data from Geonames.org (http://download.geonames.org/export/dump/countryInfo.txt)
2113

countries_plus/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import django
22

3-
APP_NAME = 'countries_plus'
4-
__version__ = '2.1.0'
3+
APP_NAME = "countries_plus"
4+
__version__ = "2.1.0"
55

66
if django.VERSION[0] == 2:
7-
default_app_config = 'countries_plus.apps.DefaultConfig'
7+
default_app_config = "countries_plus.apps.DefaultConfig"

countries_plus/admin.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55

66
class CountryAdmin(admin.ModelAdmin):
7-
list_display = ('continent', 'name', 'iso', 'iso3', 'languages', 'currency_name')
8-
list_display_links = ('name',)
9-
search_fields = ('name', 'iso', 'iso3')
7+
list_display = ("continent", "name", "iso", "iso3", "languages", "currency_name")
8+
list_display_links = ("name",)
9+
search_fields = ("name", "iso", "iso3")
1010
"""Provided so that other ModelAdmins that have """
11-
list_filter = ('continent',)
11+
list_filter = ("continent",)
1212

1313

1414
admin.site.register(Country, CountryAdmin)

countries_plus/apps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
class DefaultConfig(AppConfig):
5-
name = 'countries_plus'
5+
name = "countries_plus"
66
verbose_name = "Countries Plus"

countries_plus/context_processors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
def add_request_country(request):
22
"""Add 'country' to the request context. Requires countries_plus middleware."""
3-
return {'country': getattr(request, 'country', None)}
3+
return {"country": getattr(request, "country", None)}

countries_plus/management/commands/update_countries_plus.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class Command(BaseCommand):
7-
help = 'Updates the Countries Plus database from geonames.org'
7+
help = "Updates the Countries Plus database from geonames.org"
88

99
def handle(self, *args, **options):
1010
num_updated, num_created = update_geonames_data()

countries_plus/middleware.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ def __call__(self, request):
1515
request.country = country
1616
else:
1717
logger.warning(
18-
'countries_plus: Could not retrieve country, not adding to request.'
18+
"countries_plus: Could not retrieve country, not adding to request."
1919
)
2020
return self.get_response(request)

countries_plus/models.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
class Country(models.Model):
1212
class Meta:
13-
verbose_name = _('Country')
14-
verbose_name_plural = _('Countries')
15-
ordering = ['name']
13+
verbose_name = _("Country")
14+
verbose_name_plural = _("Countries")
15+
ordering = ["name"]
1616

1717
iso = models.CharField(max_length=2, primary_key=True)
1818
iso3 = models.CharField(max_length=3, unique=True)
@@ -36,7 +36,7 @@ class Meta:
3636
equivalent_fips_code = models.CharField(max_length=4, blank=True, null=True)
3737

3838
@staticmethod
39-
def get_by_request(request) -> 'Country':
39+
def get_by_request(request) -> "Country":
4040
"""Get a Country object from `request`, via the COUNTRIES_PLUS_COUNTRY_HEADER"""
4141

4242
country = None
@@ -61,7 +61,7 @@ def get_by_request(request) -> 'Country':
6161
except AttributeError:
6262
pass
6363

64-
geoip_request_iso = request.META.get(header_name, '')
64+
geoip_request_iso = request.META.get(header_name, "")
6565
if geoip_request_iso:
6666
try:
6767
country = Country.objects.get(iso=geoip_request_iso.upper())

0 commit comments

Comments
 (0)