From 6d13325538d8dac3b149330322f75db3d2505b61 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 18:33:59 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- push_notifications/api/rest_framework.py | 6 +++--- push_notifications/conf/app.py | 2 +- push_notifications/fields.py | 4 ++-- push_notifications/migrations/0001_initial.py | 1 - push_notifications/migrations/0002_auto_20160106_0850.py | 1 - push_notifications/migrations/0003_wnsdevice.py | 1 - push_notifications/migrations/0004_fcm.py | 1 - push_notifications/migrations/0005_applicationid.py | 1 - push_notifications/migrations/0006_webpushdevice.py | 1 - tests/test_models.py | 4 ++-- tests/test_rest_framework.py | 4 ++-- 11 files changed, 10 insertions(+), 16 deletions(-) diff --git a/push_notifications/api/rest_framework.py b/push_notifications/api/rest_framework.py index 6efff4ae..676c9022 100644 --- a/push_notifications/api/rest_framework.py +++ b/push_notifications/api/rest_framework.py @@ -22,7 +22,7 @@ def to_internal_value(self, data): data = int(data, 16) if type(data) != int else data except ValueError: raise ValidationError("Device ID is not a valid hex number") - return super(HexIntegerField, self).to_internal_value(data) + return super().to_internal_value(data) def to_representation(self, value): return value @@ -160,12 +160,12 @@ def create(self, request, *args, **kwargs): def perform_create(self, serializer): if self.request.user.is_authenticated: serializer.save(user=self.request.user) - return super(DeviceViewSetMixin, self).perform_create(serializer) + return super().perform_create(serializer) def perform_update(self, serializer): if self.request.user.is_authenticated: serializer.save(user=self.request.user) - return super(DeviceViewSetMixin, self).perform_update(serializer) + return super().perform_update(serializer) class AuthorizedMixin: diff --git a/push_notifications/conf/app.py b/push_notifications/conf/app.py index 6f0f027f..224e1f20 100644 --- a/push_notifications/conf/app.py +++ b/push_notifications/conf/app.py @@ -171,7 +171,7 @@ def _validate_apns_certificate(self, certfile): """Validate the APNS certificate at startup.""" try: - with open(certfile, "r") as f: + with open(certfile) as f: content = f.read() check_apns_certificate(content) except Exception as e: diff --git a/push_notifications/fields.py b/push_notifications/fields.py index 90eb81f0..94a1fdc2 100644 --- a/push_notifications/fields.py +++ b/push_notifications/fields.py @@ -48,7 +48,7 @@ def __init__(self, *args, **kwargs): self.default_validators = [ RegexValidator(hex_re, _("Enter a valid hexadecimal number"), "invalid") ] - super(HexadecimalField, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def prepare_value(self, value): # converts bigint from db to hex before it is displayed in admin @@ -82,7 +82,7 @@ def db_type(self, connection): elif "sqlite" == connection.vendor: return "UNSIGNED BIG INT" else: - return super(HexIntegerField, self).db_type(connection=connection) + return super().db_type(connection=connection) def get_prep_value(self, value): """ Return the integer value to be stored from the hex string """ diff --git a/push_notifications/migrations/0001_initial.py b/push_notifications/migrations/0001_initial.py index 14033f16..eca6aefd 100644 --- a/push_notifications/migrations/0001_initial.py +++ b/push_notifications/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.db import migrations, models diff --git a/push_notifications/migrations/0002_auto_20160106_0850.py b/push_notifications/migrations/0002_auto_20160106_0850.py index 37bb9f8f..8c0373dd 100644 --- a/push_notifications/migrations/0002_auto_20160106_0850.py +++ b/push_notifications/migrations/0002_auto_20160106_0850.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.1 on 2016-01-06 08:50 from django.db import migrations, models diff --git a/push_notifications/migrations/0003_wnsdevice.py b/push_notifications/migrations/0003_wnsdevice.py index 6c6b5c3a..2ac1dad9 100644 --- a/push_notifications/migrations/0003_wnsdevice.py +++ b/push_notifications/migrations/0003_wnsdevice.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.6 on 2016-06-13 20:46 import django.db.models.deletion from django.conf import settings diff --git a/push_notifications/migrations/0004_fcm.py b/push_notifications/migrations/0004_fcm.py index be35f4c4..c08c28c1 100644 --- a/push_notifications/migrations/0004_fcm.py +++ b/push_notifications/migrations/0004_fcm.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.6 on 2016-06-13 20:46 from django.conf import settings from django.db import migrations, models diff --git a/push_notifications/migrations/0005_applicationid.py b/push_notifications/migrations/0005_applicationid.py index 79b5919e..443c173d 100644 --- a/push_notifications/migrations/0005_applicationid.py +++ b/push_notifications/migrations/0005_applicationid.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.db import migrations, models diff --git a/push_notifications/migrations/0006_webpushdevice.py b/push_notifications/migrations/0006_webpushdevice.py index c63c2490..524cf6bc 100644 --- a/push_notifications/migrations/0006_webpushdevice.py +++ b/push_notifications/migrations/0006_webpushdevice.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.db import migrations, models diff --git a/tests/test_models.py b/tests/test_models.py index 89285310..b28d5725 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -276,7 +276,7 @@ def test_gcm_send_message_with_no_reg_ids(self): reg_ids = [obj.registration_id for obj in GCMDevice.objects.all()] send_bulk_message(reg_ids, {"message": "Hello World"}, "GCM") p.assert_called_once_with( - [u"abc", u"abc1"], {"message": "Hello World"}, cloud_type="GCM", application_id=None + ["abc", "abc1"], {"message": "Hello World"}, cloud_type="GCM", application_id=None ) def test_fcm_send_message(self): @@ -506,7 +506,7 @@ def test_fcm_send_message_with_no_reg_ids(self): reg_ids = [obj.registration_id for obj in GCMDevice.objects.all()] send_bulk_message(reg_ids, {"message": "Hello World"}, "FCM") p.assert_called_once_with( - [u"abc", u"abc1"], {"message": "Hello World"}, cloud_type="FCM", + ["abc", "abc1"], {"message": "Hello World"}, cloud_type="FCM", application_id=None ) diff --git a/tests/test_rest_framework.py b/tests/test_rest_framework.py index 5844ea8b..b1b46a2f 100644 --- a/tests/test_rest_framework.py +++ b/tests/test_rest_framework.py @@ -5,8 +5,8 @@ ) -GCM_DRF_INVALID_HEX_ERROR = {"device_id": [u"Device ID is not a valid hex number"]} -GCM_DRF_OUT_OF_RANGE_ERROR = {"device_id": [u"Device ID is out of range"]} +GCM_DRF_INVALID_HEX_ERROR = {"device_id": ["Device ID is not a valid hex number"]} +GCM_DRF_OUT_OF_RANGE_ERROR = {"device_id": ["Device ID is out of range"]} class APNSDeviceSerializerTestCase(TestCase):