Skip to content

Commit

Permalink
Release prep - v0.13 (#194)
Browse files Browse the repository at this point in the history
* Tidy up test app migrations
* Update pre-commit python version
  tl;dr - use highest supported to unlock language features
* Run pyupgrade
  `git ls-files -- '*.py' | xargs pyupgrade --py38-plus`
* Run Django upgrade with 3.2+
  `git ls-files --others --cached --exclude-standard -- '*.py' | xargs django-upgrade --target 3.2`
* Lint
* Bump version
  • Loading branch information
zerolab authored Feb 15, 2023
1 parent 9a8b2b7 commit cafdf36
Show file tree
Hide file tree
Showing 26 changed files with 115 additions and 191 deletions.
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ ci:
autofix_prs: false

default_language_version:
python: python3.8
python: python3.11

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand All @@ -17,7 +18,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
Expand All @@ -39,8 +40,8 @@ repos:
hooks:
- id: check-manifest
args: [--no-build-isolation]
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies: [black==22.3.0]
additional_dependencies: [black==23.1.0]
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

## Unreleased

## [0.13] - 2023-02-15

### Changed

- Testing against Wagtail 4.2 ([#193](https://github.com/torchbox/wagtailmedia/pull/193)) by @katdom13
Expand Down Expand Up @@ -216,6 +218,7 @@ Initial release

---

[0.13.0]: https://github.com/torchbox/wagtailmedia/releases/tag/v0.13.0
[0.12.0]: https://github.com/torchbox/wagtailmedia/releases/tag/v0.12.0
[0.11.1]: https://github.com/torchbox/wagtailmedia/releases/tag/v0.11.1
[0.11.0]: https://github.com/torchbox/wagtailmedia/releases/tag/v0.11.0
Expand Down
1 change: 0 additions & 1 deletion manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
line_length = 88
target-version = ['py38']
target-version = ['py311']
exclude = '''
(
/(
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env python

import io

from setuptools import find_packages, setup

from src.wagtailmedia import __version__
Expand All @@ -10,12 +8,11 @@
# Testing dependencies
testing_extras = [
# Required for running the tests
"mock>=1.0.0",
"coverage>=7.0,<8.0",
"tox>=4.0,<5.0",
]

with io.open("README.md", encoding="utf-8") as readme_file:
with open("README.md", encoding="utf-8") as readme_file:
long_description = readme_file.read()

setup(
Expand Down
2 changes: 1 addition & 1 deletion src/wagtailmedia/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.12.0"
__version__ = "0.13.0"
2 changes: 0 additions & 2 deletions src/wagtailmedia/blocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from typing import TYPE_CHECKING, Type

from django.forms import ModelChoiceField
Expand Down
2 changes: 1 addition & 1 deletion src/wagtailmedia/edit_handlers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import absolute_import, annotations, unicode_literals
from __future__ import annotations

from typing import TYPE_CHECKING

Expand Down
4 changes: 1 addition & 3 deletions src/wagtailmedia/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django import forms
from django.forms.models import modelform_factory
from django.utils.module_loading import import_string
Expand Down Expand Up @@ -43,7 +41,7 @@ class Meta:
permission_policy = media_permission_policy

def __init__(self, *args, **kwargs):
super(BaseMediaForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

if self.instance.type == "audio":
for name in ("width", "height"):
Expand Down
3 changes: 0 additions & 3 deletions src/wagtailmedia/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-04-20 12:32
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
Expand All @@ -13,7 +11,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
4 changes: 0 additions & 4 deletions src/wagtailmedia/migrations/0002_initial_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django import VERSION as DJANGO_VERSION
from django.db import migrations

Expand Down Expand Up @@ -56,7 +53,6 @@ def remove_media_permissions(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
("wagtailmedia", "0001_initial"),
# Need to run wagtailcores initial data migration to make sure the groups are created
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations


Expand Down Expand Up @@ -40,7 +37,6 @@ def remove_media_permissions_from_collections(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
("wagtailmedia", "0002_initial_data"),
("wagtailcore", "0026_group_collection_permission"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("wagtailmedia", "0003_copy_media_permissions_to_collections"),
]
Expand Down
2 changes: 0 additions & 2 deletions src/wagtailmedia/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import mimetypes
import os.path

Expand Down
1 change: 1 addition & 0 deletions src/wagtailmedia/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __check_user_settings(self, user_settings):
f"The '{setting}' setting is deprecated and will be removed in the next release, "
f'use WAGTAILMEDIA["{new_setting}"] instead.',
category=category,
stacklevel=2,
)
user_settings[new_setting] = user_settings[setting]
for setting in REMOVED_SETTINGS:
Expand Down
2 changes: 0 additions & 2 deletions src/wagtailmedia/views/media.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.core.paginator import Paginator
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
Expand Down
3 changes: 1 addition & 2 deletions src/wagtailmedia/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import include
from django.urls import path, reverse
from django.urls import include, path, reverse
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext
Expand Down
4 changes: 1 addition & 3 deletions src/wagtailmedia/widgets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, unicode_literals

import json

from django import forms
Expand Down Expand Up @@ -62,7 +60,7 @@ def render_html(self, name, value, attrs):
)

def render_js_init(self, id_, name, value):
return "createMediaChooser({0});".format(json.dumps(id_))
return f"createMediaChooser({json.dumps(id_)});"

@property
def media(self):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.core.exceptions import ValidationError
from django.core.files import File
from django.core.files.base import ContentFile
Expand Down Expand Up @@ -259,7 +257,7 @@ class TestMediaModel(TestCase):
def test_media_model(self):
cls = get_media_model()
self.assertEqual(
"%s.%s" % (cls._meta.app_label, cls.__name__),
"{}.{}".format(cls._meta.app_label, cls.__name__),
"wagtailmedia_tests.CustomMedia",
)

Expand Down
2 changes: 0 additions & 2 deletions tests/test_permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, Permission
from django.core.files.base import ContentFile
Expand Down
4 changes: 2 additions & 2 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import TestCase, override_settings
from unittest import mock

import mock
from django.test import TestCase, override_settings

from wagtailmedia.settings import WagtailMediaSettings, wagtailmedia_settings

Expand Down
16 changes: 6 additions & 10 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import json
import os

Expand Down Expand Up @@ -148,7 +146,7 @@ def test_get_audio(self):
self.assertNotContains(response, "Add audio or video")
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
'<form action="{}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse("wagtailmedia:add", args=("audio",))
),
count=1,
Expand All @@ -162,7 +160,7 @@ def test_get_video(self):
self.assertNotContains(response, "Add audio or video")
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
'<form action="{}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse("wagtailmedia:add", args=("video",))
),
count=1,
Expand Down Expand Up @@ -196,7 +194,7 @@ def test_get_audio_with_collections(self):
self.assertContains(response, "Add audio")
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
'<form action="{}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse("wagtailmedia:add", args=("audio",))
),
count=1,
Expand All @@ -215,7 +213,7 @@ def test_get_video_with_collections(self):
self.assertContains(response, "Add video")
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
'<form action="{}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse("wagtailmedia:add", args=("video",))
),
count=1,
Expand Down Expand Up @@ -375,7 +373,7 @@ def test_get_audio(self):
self.assertContains(response, "Add audio")
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
'<form action="{}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse("wagtailmedia:add", args=("audio",))
),
count=1,
Expand All @@ -392,7 +390,7 @@ def test_get_video(self):
self.assertContains(response, "Add video")
self.assertContains(
response,
'<form action="{0}" method="POST" enctype="multipart/form-data" novalidate>'.format(
'<form action="{}" method="POST" enctype="multipart/form-data" novalidate>'.format(
reverse("wagtailmedia:add", args=("video",))
),
count=1,
Expand Down Expand Up @@ -746,8 +744,6 @@ def setUpTestData(cls):
)
video.save()

cls.tab_prefix = "tab-"

def setUp(self):
self.user = self.login()

Expand Down
Loading

0 comments on commit cafdf36

Please sign in to comment.