From 713316069380ef7e314f4452807cdeaddba3493a Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Tue, 2 Jun 2020 11:24:30 +0200 Subject: [PATCH 1/5] Stop using deprecated smart_text `smart_text` is deprecated, and will be removed in the next Django major release. This change squelches warnings about that and makes sure we stay future-proof. --- django_inlinecss/templatetags/inlinecss.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_inlinecss/templatetags/inlinecss.py b/django_inlinecss/templatetags/inlinecss.py index c778ddf..82b9728 100644 --- a/django_inlinecss/templatetags/inlinecss.py +++ b/django_inlinecss/templatetags/inlinecss.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals from django import template -from django.utils.encoding import smart_text +from django.utils.encoding import smart_str from django_inlinecss import conf @@ -23,7 +23,7 @@ def render(self, context): for expression in self.filter_expressions: path = expression.resolve(context, True) if path is not None: - path = smart_text(path) + path = smart_str(path) css_loader = conf.get_css_loader()() css = ''.join((css, css_loader.load(path))) From 85602e1dff82ee47688bbcf217651a65894851ff Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Tue, 2 Jun 2020 11:29:25 +0200 Subject: [PATCH 2/5] Update supported Python versions Drop Pythons that have reached upstream EOL. Also run tests with more recent pythons. Hint: I'm using this in production in some large-scale apps with Django 3.0 and Python 3.8. It's been working fine. --- .travis.yml | 4 ++-- README.md | 2 +- django_inlinecss/conf.py | 6 ------ django_inlinecss/css_loaders.py | 7 +------ django_inlinecss/engines.py | 9 +-------- django_inlinecss/templatetags/inlinecss.py | 5 ----- django_inlinecss/tests/test_css_loaders.py | 9 ++------- django_inlinecss/tests/test_templatetags.py | 7 +------ setup.py | 20 +++----------------- test_settings.py | 5 ----- 10 files changed, 11 insertions(+), 63 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7e53f1..73536a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: python python: - - 2.7 - - 3.4 - 3.5 - 3.6 + - 3.7 + - 3.8 env: - DJANGO_VERSION=1.11 install: diff --git a/README.md b/README.md index 3a67942..73c8123 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ template language. - BeautifulSoup - cssutils -- Python 2.7+,3.4+ +- Python 3.5+ - Django 1.11+ diff --git a/django_inlinecss/conf.py b/django_inlinecss/conf.py index dc0448e..eea6976 100644 --- a/django_inlinecss/conf.py +++ b/django_inlinecss/conf.py @@ -1,9 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - - try: import importlib except ImportError: diff --git a/django_inlinecss/css_loaders.py b/django_inlinecss/css_loaders.py index 3021874..9ca636e 100644 --- a/django_inlinecss/css_loaders.py +++ b/django_inlinecss/css_loaders.py @@ -1,13 +1,8 @@ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - from django.contrib.staticfiles import finders from django.contrib.staticfiles.storage import staticfiles_storage -class BaseCSSLoader(object): +class BaseCSSLoader: def __init__(self): pass diff --git a/django_inlinecss/engines.py b/django_inlinecss/engines.py index 55ab018..8de801d 100644 --- a/django_inlinecss/engines.py +++ b/django_inlinecss/engines.py @@ -1,14 +1,7 @@ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - -from builtins import object - import pynliner -class EngineBase(object): +class EngineBase: def __init__(self, html, css): self.html = html self.css = css diff --git a/django_inlinecss/templatetags/inlinecss.py b/django_inlinecss/templatetags/inlinecss.py index 82b9728..70a4bde 100644 --- a/django_inlinecss/templatetags/inlinecss.py +++ b/django_inlinecss/templatetags/inlinecss.py @@ -1,8 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - from django import template from django.utils.encoding import smart_str diff --git a/django_inlinecss/tests/test_css_loaders.py b/django_inlinecss/tests/test_css_loaders.py index f79a1c2..fe969c3 100644 --- a/django_inlinecss/tests/test_css_loaders.py +++ b/django_inlinecss/tests/test_css_loaders.py @@ -1,11 +1,6 @@ """ Test CSS loaders """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - from django.conf import settings from django.test import TestCase from django.test import override_settings @@ -18,7 +13,7 @@ class StaticfilesFinderCSSLoaderTestCase(TestCase): def setUp(self): self.loader = StaticfilesFinderCSSLoader() - super(StaticfilesFinderCSSLoaderTestCase, self).setUp() + super().setUp() def test_loads_existing_css_file(self): css = self.loader.load('bar.css') @@ -34,7 +29,7 @@ def test_load_file_does_not_exist(self): class StaticfilesStorageCSSLoaderTestCase(TestCase): def setUp(self): self.loader = StaticfilesStorageCSSLoader() - super(StaticfilesStorageCSSLoaderTestCase, self).setUp() + super().setUp() def test_loads_existing_css_file(self): css = self.loader.load('bar.css') diff --git a/django_inlinecss/tests/test_templatetags.py b/django_inlinecss/tests/test_templatetags.py index 06d6227..9d127e8 100644 --- a/django_inlinecss/tests/test_templatetags.py +++ b/django_inlinecss/tests/test_templatetags.py @@ -4,11 +4,6 @@ The actual CSS inlining displayed here is extremely simple: tests of the CSS selector functionality is independent. """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - import os from django.conf import settings @@ -21,7 +16,7 @@ class InlinecssTests(TestCase): def setUp(self): - super(InlinecssTests, self).setUp() + super().setUp() def assert_foo_and_bar_rendered(self, rendered): foo_div_regex = ( diff --git a/setup.py b/setup.py index c1ff0c5..60ffca1 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - import io import os import sys @@ -21,14 +15,13 @@ URL = 'https://github.com/roverdotcom/django-inlinecss' EMAIL = 'philip@rover.com' AUTHOR = 'Philip Kimmey' -REQUIRES_PYTHON = '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.7' +REQUIRES_PYTHON = '>=3.5' VERSION = None # What packages are required for this module to be executed? REQUIRED = [ 'Django>=1.11', 'pynliner', - 'future>=0.16.0', ] # What packages are required only for tests? @@ -55,12 +48,6 @@ # Import the README and use it as the long-description. # Note: this will only work if 'README.md' is present in your MANIFEST.in file! -try: - # Python 3 will raise FileNotFoundError instead of IOError - FileNotFoundError = IOError -except NameError: - pass - try: with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f: long_description = '\n' + f.read() @@ -134,12 +121,11 @@ def run(self): 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Topic :: Communications :: Email', 'Topic :: Text Processing :: Markup :: HTML', ], diff --git a/test_settings.py b/test_settings.py index 08b5b85..0a91aa4 100644 --- a/test_settings.py +++ b/test_settings.py @@ -9,11 +9,6 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - import os From 998d590b565180e36ec3c96f493898891bd57372 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Tue, 2 Jun 2020 11:46:16 +0200 Subject: [PATCH 3/5] Drop support for Django 1.11 Django 1.11 has reached its EOL, and won't work with recent (and not-so-recent) versions of Python. Drop support for this; projects still using older Pythons can just keep using older versions of this library. --- .travis.yml | 2 +- README.md | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 73536a4..8bd615b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ python: - 3.7 - 3.8 env: - - DJANGO_VERSION=1.11 + - DJANGO_VERSION=2.2 install: - pip install -q Django==$DJANGO_VERSION - pip install -e .[flake8,tests] diff --git a/README.md b/README.md index 73c8123..973c180 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ template language. - BeautifulSoup - cssutils - Python 3.5+ -- Django 1.11+ +- Django 2.2+ #### Step 2: Install django_inlinecss diff --git a/setup.py b/setup.py index 60ffca1..1d82d84 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ # What packages are required for this module to be executed? REQUIRED = [ - 'Django>=1.11', + 'Django>=2.2', 'pynliner', ] From 6384ccdc04cde48f700eb882769513e038fefed9 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Tue, 2 Jun 2020 11:59:23 +0200 Subject: [PATCH 4/5] Update flake8 too --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1d82d84..3ab79b6 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ # What packages are optional? EXTRAS = { 'flake8': [ - 'flake8==3.6.0', + 'flake8==3.8.0', 'flake8-isort==2.6.0', 'isort==4.3.4', 'testfixtures==6.3.0', From 9207de83fb2e708de7780cf0d4acd31611777b97 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Tue, 2 Jun 2020 12:06:08 +0200 Subject: [PATCH 5/5] Change the CI badge to SVG The PNG one is too blurry on hidpi screens. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 973c180..da14dfb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/roverdotcom/django-inlinecss.png?branch=master)](https://travis-ci.org/roverdotcom/django-inlinecss) +[![Build Status](https://travis-ci.org/roverdotcom/django-inlinecss.svg?branch=master)](https://travis-ci.org/roverdotcom/django-inlinecss) ## About