Skip to content

Commit 2106b2e

Browse files
authored
Merge pull request #544 from leukeleu/drop-compat
Fixed #540 -- Drop support for unsupported Python and Django versions
2 parents 6296b32 + 1eeac99 commit 2106b2e

Some content is hidden

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

41 files changed

+198
-522
lines changed

.github/workflows/python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
max-parallel: 4
1515
matrix:
16-
python-version: ['2.7', '3.6', '3.7', '3.8', '3.9', '3.10']
16+
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
1717

1818
steps:
1919
- uses: actions/checkout@v2

docs/_themes/flask_theme_support.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# flasky extensions. flasky pygments style based on tango style
22
from pygments.style import Style
3-
from pygments.token import Keyword, Name, Comment, String, Error, \
4-
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
3+
from pygments.token import (Comment, Error, Generic, Keyword, Literal, Name,
4+
Number, Operator, Other, Punctuation, String,
5+
Whitespace)
56

67

78
class FlaskyStyle(Style):

docs/conf.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# ImageKit documentation build configuration file, created by
43
# sphinx-quickstart on Sun Sep 25 17:05:55 2011.
@@ -11,7 +10,9 @@
1110
# All configuration values have a default; values that are commented out
1211
# serve to show the default.
1312

14-
import re, sys, os
13+
import os
14+
import re
15+
import sys
1516

1617
# If extensions (or modules to document with autodoc) are in another directory,
1718
# add these directories to sys.path here. If the directory is relative to the
@@ -42,8 +43,8 @@
4243
master_doc = 'index'
4344

4445
# General information about the project.
45-
project = u'ImageKit'
46-
copyright = u'2011, Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett & Matthew Tretter'
46+
project = 'ImageKit'
47+
copyright = '2011, Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett & Matthew Tretter'
4748

4849
pkgmeta = {}
4950
execfile(os.path.join(os.path.dirname(__file__), '..', 'imagekit',
@@ -189,8 +190,8 @@
189190
# Grouping the document tree into LaTeX files. List of tuples
190191
# (source start file, target name, title, author, documentclass [howto/manual]).
191192
latex_documents = [
192-
('index', 'ImageKit.tex', u'ImageKit Documentation',
193-
u'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett \\& Matthew Tretter', 'manual'),
193+
('index', 'ImageKit.tex', 'ImageKit Documentation',
194+
'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett \\& Matthew Tretter', 'manual'),
194195
]
195196

196197
# The name of an image file (relative to this directory) to place at the top of
@@ -219,8 +220,8 @@
219220
# One entry per manual page. List of tuples
220221
# (source start file, name, description, authors, manual section).
221222
man_pages = [
222-
('index', 'imagekit', u'ImageKit Documentation',
223-
[u'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett & Matthew Tretter'], 1)
223+
('index', 'imagekit', 'ImageKit Documentation',
224+
['Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett & Matthew Tretter'], 1)
224225
]
225226

226227
# If true, show URL addresses after external links.
@@ -233,7 +234,7 @@
233234
# (source start file, target name, title, author,
234235
# dir menu entry, description, category)
235236
texinfo_documents = [
236-
('index', 'ImageKit', u'ImageKit Documentation', u'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett & Matthew Tretter',
237+
('index', 'ImageKit', 'ImageKit Documentation', 'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett & Matthew Tretter',
237238
'ImageKit', 'One line description of project.', 'Miscellaneous'),
238239
]
239240

imagekit/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# flake8: noqa
2-
from . import conf
3-
from . import generatorlibrary
4-
from .specs import ImageSpec
1+
from . import conf, generatorlibrary
52
from .pkgmeta import *
63
from .registry import register, unregister
4+
from .specs import ImageSpec
5+
6+
__all__ = [
7+
'ImageSpec', 'conf', 'generatorlibrary', 'register', 'unregister',
8+
'__title__', '__author__', '__version__', '__license__'
9+
]

imagekit/admin.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
from django import VERSION
2-
if VERSION[0] < 2:
3-
# ugettext is an alias for gettext() since Django 2.0,
4-
# and deprecated as of Django 3.0.
5-
from django.utils.translation import ugettext_lazy as _
6-
else:
7-
from django.utils.translation import gettext_lazy as _
81
from django.template.loader import render_to_string
2+
from django.utils.translation import gettext_lazy as _
93

104

11-
class AdminThumbnail(object):
5+
class AdminThumbnail:
126
"""
137
A convenience utility for adding thumbnails to Django's admin change list.
148

imagekit/cachefiles/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from copy import copy
2+
23
from django.conf import settings
34
from django.core.files import File
45
from django.core.files.images import ImageFile
5-
from django.utils.functional import SimpleLazyObject
66
from django.utils.encoding import smart_str
7+
from django.utils.functional import SimpleLazyObject
8+
79
from ..files import BaseIKFile
810
from ..registry import generator_registry
911
from ..signals import content_required, existence_required
10-
from ..utils import get_logger, get_singleton, generate, get_by_qname
12+
from ..utils import generate, get_by_qname, get_logger, get_singleton
1113

1214

1315
class ImageCacheFile(BaseIKFile, ImageFile):
@@ -55,7 +57,7 @@ def __init__(self, generator, name=None, storage=None, cachefile_backend=None, c
5557
'cache file strategy')
5658
)
5759

58-
super(ImageCacheFile, self).__init__(storage=storage)
60+
super().__init__(storage=storage)
5961

6062
def _require_file(self):
6163
if getattr(self, '_file', None) is None:
@@ -162,10 +164,6 @@ def __setstate__(self, state):
162164
)
163165
self.__dict__.update(state)
164166

165-
def __nonzero__(self):
166-
# Python 2 compatibility
167-
return self.__bool__()
168-
169167
def __repr__(self):
170168
return smart_str("<%s: %s>" % (
171169
self.__class__.__name__, self if self.name else "None")
@@ -177,7 +175,7 @@ def __init__(self, generator_id, *args, **kwargs):
177175
def setup():
178176
generator = generator_registry.get(generator_id, *args, **kwargs)
179177
return ImageCacheFile(generator)
180-
super(LazyImageCacheFile, self).__init__(setup)
178+
super().__init__(setup)
181179

182180
def __repr__(self):
183181
return '<%s: %s>' % (self.__class__.__name__, str(self) or 'None')

imagekit/cachefiles/backends.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
from ..utils import get_singleton, get_cache, sanitize_cache_key
21
import warnings
32
from copy import copy
4-
from django.core.exceptions import ImproperlyConfigured
3+
54
from django.conf import settings
5+
from django.core.exceptions import ImproperlyConfigured
6+
7+
from ..utils import get_cache, get_singleton, sanitize_cache_key
68

79

8-
class CacheFileState(object):
10+
class CacheFileState:
911
EXISTS = 'exists'
1012
GENERATING = 'generating'
1113
DOES_NOT_EXIST = 'does_not_exist'
@@ -25,7 +27,7 @@ class InvalidFileBackendError(ImproperlyConfigured):
2527
pass
2628

2729

28-
class AbstractCacheFileBackend(object):
30+
class AbstractCacheFileBackend:
2931
"""
3032
An abstract cache file backend. This isn't used by any internal classes and
3133
is included simply to illustrate the minimum interface of a cache file
@@ -39,7 +41,7 @@ def exists(self, file):
3941
raise NotImplementedError
4042

4143

42-
class CachedFileBackend(object):
44+
class CachedFileBackend:
4345
existence_check_timeout = 5
4446
"""
4547
The number of seconds to wait before rechecking to see if the file exists.
@@ -157,7 +159,7 @@ def __init__(self, *args, **kwargs):
157159
except ImportError:
158160
raise ImproperlyConfigured('You must install celery to use'
159161
' imagekit.cachefiles.backends.Celery.')
160-
super(Celery, self).__init__(*args, **kwargs)
162+
super().__init__(*args, **kwargs)
161163

162164
def schedule_generation(self, file, force=False):
163165
_celery_task.delay(self, file, force=force)
@@ -168,7 +170,7 @@ class Async(Celery):
168170
def __init__(self, *args, **kwargs):
169171
message = '{path}.Async is deprecated. Use {path}.Celery instead.'
170172
warnings.warn(message.format(path=__name__), DeprecationWarning)
171-
super(Async, self).__init__(*args, **kwargs)
173+
super().__init__(*args, **kwargs)
172174

173175

174176
try:
@@ -189,7 +191,7 @@ def __init__(self, *args, **kwargs):
189191
except ImportError:
190192
raise ImproperlyConfigured('You must install django-rq to use'
191193
' imagekit.cachefiles.backends.RQ.')
192-
super(RQ, self).__init__(*args, **kwargs)
194+
super().__init__(*args, **kwargs)
193195

194196
def schedule_generation(self, file, force=False):
195197
_rq_job.delay(self, file, force=force)
@@ -213,7 +215,7 @@ def __init__(self, *args, **kwargs):
213215
except ImportError:
214216
raise ImproperlyConfigured('You must install django-dramatiq to use'
215217
' imagekit.cachefiles.backends.Dramatiq.')
216-
super(Dramatiq, self).__init__(*args, **kwargs)
218+
super().__init__(*args, **kwargs)
217219

218220
def schedule_generation(self, file, force=False):
219221
_dramatiq_actor.send(self, file, force=force)

imagekit/cachefiles/namers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
66
"""
77

8-
from django.conf import settings
98
import os
9+
10+
from django.conf import settings
11+
1012
from ..utils import format_to_extension, suggest_extension
1113

1214

imagekit/cachefiles/strategies.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import six
2-
3-
from django.utils.functional import LazyObject
4-
from ..lib import force_text
51
from ..utils import get_singleton
62

73

8-
class JustInTime(object):
4+
class JustInTime:
95
"""
106
A strategy that ensures the file exists right before it's needed.
117
@@ -18,7 +14,7 @@ def on_content_required(self, file):
1814
file.generate()
1915

2016

21-
class Optimistic(object):
17+
class Optimistic:
2218
"""
2319
A strategy that acts immediately when the source file changes and assumes
2420
that the cache files will not be removed (i.e. it doesn't ensure the
@@ -33,14 +29,14 @@ def should_verify_existence(self, file):
3329
return False
3430

3531

36-
class DictStrategy(object):
32+
class DictStrategy:
3733
def __init__(self, callbacks):
3834
for k, v in callbacks.items():
3935
setattr(self, k, v)
4036

4137

4238
def load_strategy(strategy):
43-
if isinstance(strategy, six.string_types):
39+
if isinstance(strategy, str):
4440
strategy = get_singleton(strategy, 'cache file strategy')
4541
elif isinstance(strategy, dict):
4642
strategy = DictStrategy(strategy)

0 commit comments

Comments
 (0)