From 154f76ce067fac570ab68e340a250ab197ed18f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 20 Feb 2020 19:26:00 +0100 Subject: [PATCH] Misc: Remove object inheritance It is not needed with Python 3. Issue #2201 --- weblate/accounts/captcha.py | 2 +- weblate/accounts/forms.py | 12 +++++------ weblate/accounts/middleware.py | 4 ++-- weblate/accounts/models.py | 4 ++-- weblate/accounts/notifications.py | 2 +- weblate/accounts/password_validation.py | 4 ++-- weblate/addons/base.py | 2 +- weblate/addons/forms.py | 2 +- weblate/addons/models.py | 4 ++-- weblate/api/serializers.py | 18 ++++++++-------- weblate/api/views.py | 2 +- weblate/auth/admin.py | 2 +- weblate/auth/models.py | 6 +++--- weblate/checks/base.py | 2 +- weblate/checks/flags.py | 2 +- weblate/checks/models.py | 4 ++-- weblate/checks/tests/test_checks.py | 10 ++++----- weblate/fonts/forms.py | 6 +++--- weblate/fonts/models.py | 6 +++--- weblate/formats/base.py | 4 ++-- weblate/formats/exporters.py | 2 +- weblate/formats/models.py | 2 +- weblate/formats/tests/test_formats.py | 2 +- weblate/formats/txt.py | 8 +++---- weblate/lang/forms.py | 4 ++-- weblate/lang/models.py | 6 +++--- weblate/legal/middleware.py | 2 +- weblate/machinery/base.py | 2 +- weblate/machinery/models.py | 2 +- weblate/middleware.py | 4 ++-- weblate/screenshots/forms.py | 2 +- weblate/trans/admin.py | 2 +- weblate/trans/autofixes/base.py | 2 +- weblate/trans/autotranslate.py | 2 +- weblate/trans/discovery.py | 2 +- weblate/trans/filter.py | 2 +- weblate/trans/forms.py | 28 ++++++++++++------------- weblate/trans/mixins.py | 6 +++--- weblate/trans/models/_conf.py | 2 +- weblate/trans/models/agreement.py | 2 +- weblate/trans/models/alert.py | 4 ++-- weblate/trans/models/change.py | 2 +- weblate/trans/models/comment.py | 2 +- weblate/trans/models/component.py | 2 +- weblate/trans/models/componentlist.py | 4 ++-- weblate/trans/models/dictionary.py | 2 +- weblate/trans/models/label.py | 2 +- weblate/trans/models/project.py | 2 +- weblate/trans/models/shaping.py | 2 +- weblate/trans/models/suggestion.py | 4 ++-- weblate/trans/models/translation.py | 2 +- weblate/trans/models/unit.py | 2 +- weblate/trans/models/whiteboard.py | 2 +- weblate/trans/tests/test_views.py | 2 +- weblate/trans/tests/utils.py | 4 ++-- weblate/trans/views/guide.py | 2 +- weblate/trans/widgets.py | 2 +- weblate/utils/classloader.py | 2 +- weblate/utils/forms.py | 2 +- weblate/utils/index.py | 2 +- weblate/utils/models.py | 2 +- weblate/utils/search.py | 2 +- weblate/utils/stats.py | 4 ++-- weblate/utils/views.py | 4 ++-- weblate/vcs/base.py | 2 +- weblate/vcs/models.py | 2 +- weblate/vcs/ssh.py | 2 +- weblate/wladmin/forms.py | 2 +- weblate/wladmin/models.py | 2 +- 69 files changed, 126 insertions(+), 126 deletions(-) diff --git a/weblate/accounts/captcha.py b/weblate/accounts/captcha.py index 0a2f9d7a4e8f..218fa9bc3944 100644 --- a/weblate/accounts/captcha.py +++ b/weblate/accounts/captcha.py @@ -33,7 +33,7 @@ OPERATORS = {ast.Add: operator.add, ast.Sub: operator.sub, ast.Mult: operator.mul} -class MathCaptcha(object): +class MathCaptcha: """Simple match captcha object.""" operators = ('+', '-', '*') diff --git a/weblate/accounts/forms.py b/weblate/accounts/forms.py index 99bd71f2ebf9..96f963be67be 100644 --- a/weblate/accounts/forms.py +++ b/weblate/accounts/forms.py @@ -66,7 +66,7 @@ ) -class UniqueEmailMixin(object): +class UniqueEmailMixin: validate_unique_mail = False def clean_email(self): @@ -162,7 +162,7 @@ def from_request(cls, request): class ProfileForm(ProfileBaseForm): """User profile editing.""" - class Meta(object): + class Meta: model = Profile fields = ('language', 'languages', 'secondary_languages') widgets = { @@ -185,7 +185,7 @@ def __init__(self, *args, **kwargs): class SubscriptionForm(ProfileBaseForm): """User watched projects management.""" - class Meta(object): + class Meta: model = Profile fields = ('watched',) widgets = {'watched': forms.SelectMultiple} @@ -204,7 +204,7 @@ def __init__(self, *args, **kwargs): class UserSettingsForm(ProfileBaseForm): """User settings form.""" - class Meta(object): + class Meta: model = Profile fields = ( 'hide_completed', @@ -226,7 +226,7 @@ def __init__(self, *args, **kwargs): class DashboardSettingsForm(ProfileBaseForm): """Dashboard settings form.""" - class Meta(object): + class Meta: model = Profile fields = ('dashboard_view', 'dashboard_component_list') widgets = {'dashboard_view': forms.RadioSelect} @@ -250,7 +250,7 @@ class UserForm(forms.ModelForm): ) full_name = FullNameField() - class Meta(object): + class Meta: model = User fields = ('username', 'full_name', 'email') diff --git a/weblate/accounts/middleware.py b/weblate/accounts/middleware.py index 82382d19e54d..043bff3a0805 100644 --- a/weblate/accounts/middleware.py +++ b/weblate/accounts/middleware.py @@ -48,7 +48,7 @@ def get_user(request): return request._cached_user -class AuthenticationMiddleware(object): +class AuthenticationMiddleware: """Copy of django.contrib.auth.middleware.AuthenticationMiddleware.""" def __init__(self, get_response=None): @@ -59,7 +59,7 @@ def __call__(self, request): return self.get_response(request) -class RequireLoginMiddleware(object): +class RequireLoginMiddleware: """Middleware that applies the login_required decorator to matching URL patterns. To use, add the class to MIDDLEWARE and diff --git a/weblate/accounts/models.py b/weblate/accounts/models.py index ded23a7ac380..52d500ebfc00 100644 --- a/weblate/accounts/models.py +++ b/weblate/accounts/models.py @@ -63,7 +63,7 @@ class Subscription(models.Model): 'trans.Component', on_delete=models.deletion.CASCADE, null=True ) - class Meta(object): + class Meta: unique_together = [('notification', 'scope', 'project', 'component', 'user')] def __str__(self): @@ -593,5 +593,5 @@ class WeblateAccountsConf(AppConf): r'/legal/(.*)$', # Optional for legal app ) - class Meta(object): + class Meta: prefix = '' diff --git a/weblate/accounts/notifications.py b/weblate/accounts/notifications.py index 6a225593dca1..f933b607441b 100644 --- a/weblate/accounts/notifications.py +++ b/weblate/accounts/notifications.py @@ -84,7 +84,7 @@ def register_notification(handler): return handler -class Notification(object): +class Notification: actions = () verbose = '' template_name = None diff --git a/weblate/accounts/password_validation.py b/weblate/accounts/password_validation.py index 4644f22c259a..c9b8b78b37b1 100644 --- a/weblate/accounts/password_validation.py +++ b/weblate/accounts/password_validation.py @@ -26,7 +26,7 @@ from weblate.accounts.models import AuditLog -class CharsPasswordValidator(object): +class CharsPasswordValidator: """Validate whether the password is not only whitespace or single char.""" def validate(self, password, user=None): @@ -50,7 +50,7 @@ def get_help_text(self): ) -class PastPasswordsValidator(object): +class PastPasswordsValidator: """Validate whether the password was not used before.""" def validate(self, password, user=None): diff --git a/weblate/addons/base.py b/weblate/addons/base.py index 6c18106d34a0..6f47e8750ddd 100644 --- a/weblate/addons/base.py +++ b/weblate/addons/base.py @@ -44,7 +44,7 @@ from weblate.utils.validators import validate_filename -class BaseAddon(object): +class BaseAddon: events = () settings_form = None name = None diff --git a/weblate/addons/forms.py b/weblate/addons/forms.py index 7235730e1e26..5f9e41c0459e 100644 --- a/weblate/addons/forms.py +++ b/weblate/addons/forms.py @@ -34,7 +34,7 @@ from weblate.utils.validators import validate_filename, validate_re -class AddonFormMixin(object): +class AddonFormMixin: def serialize_form(self): return self.cleaned_data diff --git a/weblate/addons/models.py b/weblate/addons/models.py index b94d225d8f2b..88889903a6fe 100644 --- a/weblate/addons/models.py +++ b/weblate/addons/models.py @@ -125,7 +125,7 @@ class Event(models.Model): addon = models.ForeignKey(Addon, on_delete=models.deletion.CASCADE) event = models.IntegerField(choices=EVENT_CHOICES) - class Meta(object): + class Meta: unique_together = ('addon', 'event') def __str__(self): @@ -158,7 +158,7 @@ class AddonsConf(AppConf): 'weblate.addons.yaml.YAMLCustomizeAddon', ) - class Meta(object): + class Meta: prefix = 'WEBLATE' diff --git a/weblate/api/serializers.py b/weblate/api/serializers.py index e8a6fe841dcb..0900f095fb0e 100644 --- a/weblate/api/serializers.py +++ b/weblate/api/serializers.py @@ -82,7 +82,7 @@ def __init__(self, *args, **kwargs): class LanguageSerializer(serializers.ModelSerializer): web_url = AbsoluteURLField(source='get_absolute_url', read_only=True) - class Meta(object): + class Meta: model = Language fields = ('code', 'name', 'direction', 'web_url', 'url') extra_kwargs = { @@ -109,7 +109,7 @@ class ProjectSerializer(serializers.ModelSerializer): view_name='api:project-languages', lookup_field='slug' ) - class Meta(object): + class Meta: model = Project fields = ( 'name', @@ -165,7 +165,7 @@ class ComponentSerializer(RemovableSerializer): serializer_url_field = MultiFieldHyperlinkedIdentityField - class Meta(object): + class Meta: model = Component fields = ( 'name', @@ -269,7 +269,7 @@ class TranslationSerializer(RemovableSerializer): serializer_url_field = MultiFieldHyperlinkedIdentityField - class Meta(object): + class Meta: model = Translation fields = ( 'language', @@ -325,7 +325,7 @@ def create(self, validated_data): class LockSerializer(serializers.ModelSerializer): - class Meta(object): + class Meta: model = Component fields = ('locked',) @@ -389,7 +389,7 @@ class UnitSerializer(RemovableSerializer): strip_parts=1, ) - class Meta(object): + class Meta: model = Unit fields = ( 'translation', @@ -430,7 +430,7 @@ class ScreenshotSerializer(RemovableSerializer): many=True, read_only=True, view_name='api:unit-detail' ) - class Meta(object): + class Meta: model = Screenshot fields = ('name', 'component', 'file_url', 'units', 'url') extra_kwargs = {'url': {'view_name': 'api:screenshot-detail'}} @@ -439,7 +439,7 @@ class Meta(object): class ScreenshotFileSerializer(serializers.ModelSerializer): image = serializers.ImageField(validators=[validate_bitmap]) - class Meta(object): + class Meta: model = Screenshot fields = ('image',) extra_kwargs = {'url': {'view_name': 'api:screenshot-file'}} @@ -465,7 +465,7 @@ class ChangeSerializer(RemovableSerializer): read_only=True, view_name='api:unit-detail' ) - class Meta(object): + class Meta: model = Change fields = ( 'unit', diff --git a/weblate/api/views.py b/weblate/api/views.py index ca240cb23a9f..744f1a3d675a 100644 --- a/weblate/api/views.py +++ b/weblate/api/views.py @@ -112,7 +112,7 @@ def get_view_description(view_cls, html=False): return description -class MultipleFieldMixin(object): +class MultipleFieldMixin: """Multiple field filtering mixin. Apply this mixin to any view or viewset to get multiple field filtering based on a diff --git a/weblate/auth/admin.py b/weblate/auth/admin.py index 68ab3fdaf0b4..5abb72a75fa7 100644 --- a/weblate/auth/admin.py +++ b/weblate/auth/admin.py @@ -79,7 +79,7 @@ def __init__(self, *args, **kwargs): class WeblateUserCreationForm(UserCreationForm, UniqueEmailMixin): validate_unique_mail = True - class Meta(object): + class Meta: model = User fields = ('username', 'email', 'full_name') field_classes = {'username': UsernameField, 'full_name': FullNameField} diff --git a/weblate/auth/models.py b/weblate/auth/models.py index 34fbaec3e20b..a5d2c5c759b4 100644 --- a/weblate/auth/models.py +++ b/weblate/auth/models.py @@ -67,7 +67,7 @@ class Permission(models.Model): codename = models.CharField(max_length=100, unique=True) name = models.CharField(max_length=200) - class Meta(object): + class Meta: verbose_name = _('Permission') verbose_name_plural = _('Permissions') @@ -494,7 +494,7 @@ class AutoGroup(models.Model): Group, verbose_name=_('Group to assign'), on_delete=models.deletion.CASCADE ) - class Meta(object): + class Meta: verbose_name = _('Automatic group assignment') verbose_name_plural = _('Automatic group assignments') @@ -659,5 +659,5 @@ class WeblateAuthConf(AppConf): # Anonymous user name ANONYMOUS_USER_NAME = 'anonymous' - class Meta(object): + class Meta: prefix = '' diff --git a/weblate/checks/base.py b/weblate/checks/base.py index 88d258ba09ca..d290e3b07dc4 100644 --- a/weblate/checks/base.py +++ b/weblate/checks/base.py @@ -23,7 +23,7 @@ from weblate.utils.docs import get_doc_url -class Check(object): +class Check: """Basic class for checks.""" check_id = '' diff --git a/weblate/checks/flags.py b/weblate/checks/flags.py index 8766a6688511..8fe7162bbb1b 100644 --- a/weblate/checks/flags.py +++ b/weblate/checks/flags.py @@ -61,7 +61,7 @@ IGNORE_CHECK_FLAGS = {CHECKS[x].ignore_string for x in CHECKS} -class Flags(object): +class Flags: def __init__(self, *args): self._items = {} self._values = {} diff --git a/weblate/checks/models.py b/weblate/checks/models.py index 715036098283..f7c6639772e1 100644 --- a/weblate/checks/models.py +++ b/weblate/checks/models.py @@ -85,7 +85,7 @@ class WeblateChecksConf(AppConf): 'weblate.checks.source.MultipleFailingCheck', ) - class Meta(object): + class Meta: prefix = '' @@ -101,7 +101,7 @@ def check_obj(self): except KeyError: return None - class Meta(object): + class Meta: unique_together = ('unit', 'check') def __str__(self): diff --git a/weblate/checks/tests/test_checks.py b/weblate/checks/tests/test_checks.py index d536e75dd8bd..7fa67be89ce0 100644 --- a/weblate/checks/tests/test_checks.py +++ b/weblate/checks/tests/test_checks.py @@ -31,7 +31,7 @@ class MockLanguage(Language): """Mock language object.""" - class Meta(object): + class Meta: proxy = True def __init__(self, code='cs'): @@ -39,7 +39,7 @@ def __init__(self, code='cs'): self.plural = Plural(language=self) -class MockProject(object): +class MockProject: """Mock project object.""" def __init__(self): @@ -48,7 +48,7 @@ def __init__(self): self.use_shared_tm = True -class MockComponent(object): +class MockComponent: """Mock component object.""" def __init__(self): @@ -56,7 +56,7 @@ def __init__(self): self.project = MockProject() -class MockTranslation(object): +class MockTranslation: """Mock translation object.""" def __init__(self, code='cs'): @@ -66,7 +66,7 @@ def __init__(self, code='cs'): self.is_source = False -class MockUnit(object): +class MockUnit: """Mock unit object.""" def __init__(self, id_hash=None, flags='', code='cs', source='', note=''): diff --git a/weblate/fonts/forms.py b/weblate/fonts/forms.py index b82e2f3de452..7835d016916c 100644 --- a/weblate/fonts/forms.py +++ b/weblate/fonts/forms.py @@ -25,13 +25,13 @@ class FontForm(forms.ModelForm): - class Meta(object): + class Meta: model = Font fields = ("font",) class FontGroupForm(forms.ModelForm): - class Meta(object): + class Meta: model = FontGroup fields = ("name", "font") @@ -43,6 +43,6 @@ def __init__(self, data=None, project=None, **kwargs): class FontOverrideForm(forms.ModelForm): - class Meta(object): + class Meta: model = FontOverride fields = ("language", "font") diff --git a/weblate/fonts/models.py b/weblate/fonts/models.py index c857221c7b70..3e6d885414fd 100644 --- a/weblate/fonts/models.py +++ b/weblate/fonts/models.py @@ -54,7 +54,7 @@ class Font(models.Model, UserDisplayMixin): on_delete=models.deletion.SET_NULL, ) - class Meta(object): + class Meta: unique_together = [("family", "style", "project")] def __init__(self, *args, **kwargs): @@ -117,7 +117,7 @@ class FontGroup(models.Model): objects = FontGroupQuerySet.as_manager() - class Meta(object): + class Meta: unique_together = [("name", "project")] def __str__(self): @@ -138,7 +138,7 @@ class FontOverride(models.Model): Language, on_delete=models.deletion.CASCADE, verbose_name=_("Language") ) - class Meta(object): + class Meta: unique_together = [("group", "language")] def __str__(self): diff --git a/weblate/formats/base.py b/weblate/formats/base.py index 5df2b0367393..c536441c8f5b 100644 --- a/weblate/formats/base.py +++ b/weblate/formats/base.py @@ -34,7 +34,7 @@ class UnitNotFound(Exception): pass -class TranslationUnit(object): +class TranslationUnit: """Wrapper for translate-toolkit unit. It handles ID/template based translations and other API differences. @@ -143,7 +143,7 @@ def mark_approved(self, value): raise NotImplementedError() -class TranslationFormat(object): +class TranslationFormat: """Generic object defining file format loader.""" name = '' diff --git a/weblate/formats/exporters.py b/weblate/formats/exporters.py index 2f9167d55e26..3cb330923f56 100644 --- a/weblate/formats/exporters.py +++ b/weblate/formats/exporters.py @@ -62,7 +62,7 @@ def list_exporters(translation): ] -class BaseExporter(object): +class BaseExporter: content_type = 'text/plain' extension = 'txt' name = '' diff --git a/weblate/formats/models.py b/weblate/formats/models.py index c1972a30aa02..c236bccf7cd9 100644 --- a/weblate/formats/models.py +++ b/weblate/formats/models.py @@ -94,5 +94,5 @@ class FormatsConf(AppConf): 'weblate.formats.txt.AppStoreFormat', ) - class Meta(object): + class Meta: prefix = 'WEBLATE' diff --git a/weblate/formats/tests/test_formats.py b/weblate/formats/tests/test_formats.py index 911ef23221a9..c43239ffe16b 100644 --- a/weblate/formats/tests/test_formats.py +++ b/weblate/formats/tests/test_formats.py @@ -296,7 +296,7 @@ def test_flags(self): break -class XMLMixin(object): +class XMLMixin: def assert_same(self, newdata, testdata): self.assertXMLEqual(force_text(newdata), force_text(testdata)) diff --git a/weblate/formats/txt.py b/weblate/formats/txt.py index 9e5a48c1e274..f43626c13ef0 100644 --- a/weblate/formats/txt.py +++ b/weblate/formats/txt.py @@ -32,7 +32,7 @@ from weblate.utils.errors import report_error -class TextItem(object): +class TextItem: """Actual text unit object.""" def __init__(self, filename, line, text, flags=None): @@ -49,7 +49,7 @@ def getid(self): return self.location -class TextParser(object): +class TextParser: """Simple text parser returning all content as single unit.""" def __init__(self, storefile, filename=None, flags=None): @@ -62,7 +62,7 @@ def __init__(self, storefile, filename=None, flags=None): self.units = [TextItem(self.filename, 1, content.strip(), flags)] -class TextSerializer(object): +class TextSerializer: def __init__(self, filename, units): self.units = [unit for unit in units if unit.filename == filename] @@ -72,7 +72,7 @@ def __call__(self, handle): handle.write(b'\n') -class MultiParser(object): +class MultiParser: filenames = () def __init__(self, storefile): diff --git a/weblate/lang/forms.py b/weblate/lang/forms.py index ff036191596c..54238b9157b0 100644 --- a/weblate/lang/forms.py +++ b/weblate/lang/forms.py @@ -25,12 +25,12 @@ class LanguageForm(forms.ModelForm): - class Meta(object): + class Meta: model = Language exclude = [] class PluralForm(forms.ModelForm): - class Meta(object): + class Meta: model = Plural fields = ["number", "equation"] diff --git a/weblate/lang/models.py b/weblate/lang/models.py index 836dd5bb4127..6ae00e103ba3 100644 --- a/weblate/lang/models.py +++ b/weblate/lang/models.py @@ -390,7 +390,7 @@ class Language(models.Model): objects = LanguageQuerySet.as_manager() - class Meta(object): + class Meta: verbose_name = gettext_lazy('Language') verbose_name_plural = gettext_lazy('Languages') @@ -519,7 +519,7 @@ class Plural(models.Model): objects = PluralQuerySet.as_manager() - class Meta(object): + class Meta: verbose_name = gettext_lazy('Plural form') verbose_name_plural = gettext_lazy('Plural forms') @@ -634,5 +634,5 @@ class WeblateLanguagesConf(AppConf): # Use simple language codes for default language/country combinations SIMPLIFY_LANGUAGES = True - class Meta(object): + class Meta: prefix = '' diff --git a/weblate/legal/middleware.py b/weblate/legal/middleware.py index 3ae5db265882..3bbcab6eabb4 100644 --- a/weblate/legal/middleware.py +++ b/weblate/legal/middleware.py @@ -29,7 +29,7 @@ from weblate.utils import messages -class RequireTOSMiddleware(object): +class RequireTOSMiddleware: """Middleware to enforce TOS confirmation on certain requests.""" def __init__(self, get_response=None): diff --git a/weblate/machinery/base.py b/weblate/machinery/base.py index dfb59cd8523e..275323f7df71 100644 --- a/weblate/machinery/base.py +++ b/weblate/machinery/base.py @@ -46,7 +46,7 @@ class MissingConfiguration(ImproperlyConfigured): """Exception raised when configuraiton is wrong.""" -class MachineTranslation(object): +class MachineTranslation: """Generic object for machine translation services.""" name = 'MT' diff --git a/weblate/machinery/models.py b/weblate/machinery/models.py index d96666a61d0d..0539622caf36 100644 --- a/weblate/machinery/models.py +++ b/weblate/machinery/models.py @@ -83,5 +83,5 @@ class WeblateConf(AppConf): 'weblate.memory.machine.WeblateMemory', ) - class Meta(object): + class Meta: prefix = 'MT' diff --git a/weblate/middleware.py b/weblate/middleware.py index 6a065adf0df8..2188c9120065 100644 --- a/weblate/middleware.py +++ b/weblate/middleware.py @@ -37,7 +37,7 @@ INLINE_PATHS = {"social:begin"} -class ProxyMiddleware(object): +class ProxyMiddleware: """Middleware that updates REMOTE_ADDR from proxy. Note that this can have security implications and settings have to match your actual @@ -63,7 +63,7 @@ def __call__(self, request): return self.get_response(request) -class SecurityMiddleware(object): +class SecurityMiddleware: """Middleware that sets Content-Security-Policy.""" def __init__(self, get_response=None): diff --git a/weblate/screenshots/forms.py b/weblate/screenshots/forms.py index 19a0aa66c420..9b54085e076b 100644 --- a/weblate/screenshots/forms.py +++ b/weblate/screenshots/forms.py @@ -27,6 +27,6 @@ class ScreenshotForm(forms.ModelForm): """User profile editing.""" - class Meta(object): + class Meta: model = Screenshot fields = ('name', 'image') diff --git a/weblate/trans/admin.py b/weblate/trans/admin.py index f6881185deea..5d0d2df6a238 100644 --- a/weblate/trans/admin.py +++ b/weblate/trans/admin.py @@ -27,7 +27,7 @@ from weblate.wladmin.models import WeblateModelAdmin -class RepoAdminMixin(object): +class RepoAdminMixin: def force_commit(self, request, queryset): """Commit pending changes for selected components.""" for obj in queryset: diff --git a/weblate/trans/autofixes/base.py b/weblate/trans/autofixes/base.py index a30f131f0e9d..598b022c57f5 100644 --- a/weblate/trans/autofixes/base.py +++ b/weblate/trans/autofixes/base.py @@ -19,7 +19,7 @@ # -class AutoFix(object): +class AutoFix: """Base class for AutoFixes.""" fix_id = 'auto' diff --git a/weblate/trans/autotranslate.py b/weblate/trans/autotranslate.py index fec358592160..e85385013a10 100644 --- a/weblate/trans/autotranslate.py +++ b/weblate/trans/autotranslate.py @@ -27,7 +27,7 @@ from weblate.utils.state import STATE_FUZZY, STATE_TRANSLATED -class AutoTranslate(object): +class AutoTranslate: def __init__(self, user, translation, filter_type, mode): self.user = user self.translation = translation diff --git a/weblate/trans/discovery.py b/weblate/trans/discovery.py index 95796150bd21..746f739f8918 100644 --- a/weblate/trans/discovery.py +++ b/weblate/trans/discovery.py @@ -62,7 +62,7 @@ ) -class ComponentDiscovery(object): +class ComponentDiscovery: def __init__( self, component, diff --git a/weblate/trans/filter.py b/weblate/trans/filter.py index 351bf95ff558..34c33f82996a 100644 --- a/weblate/trans/filter.py +++ b/weblate/trans/filter.py @@ -26,7 +26,7 @@ from weblate.checks import CHECKS -class FilterRegistry(object): +class FilterRegistry: @cached_property def full_list(self): result = [ diff --git a/weblate/trans/forms.py b/weblate/trans/forms.py index 94a3b5549420..8addfff51f58 100644 --- a/weblate/trans/forms.py +++ b/weblate/trans/forms.py @@ -1020,7 +1020,7 @@ def get_new_language_form(request, component): class ContextForm(forms.ModelForm): - class Meta(object): + class Meta: model = Unit fields = ('extra_context', 'labels', 'extra_flags') widgets = {'labels': forms.CheckboxSelectMultiple()} @@ -1054,7 +1054,7 @@ class UserManageForm(forms.Form): class InviteUserForm(forms.ModelForm): - class Meta(object): + class Meta: model = User fields = ['email', 'full_name'] @@ -1185,7 +1185,7 @@ def clean(self): raise ValidationError({'start_date': msg, 'end_date': msg}) -class CleanRepoMixin(object): +class CleanRepoMixin: def clean_repo(self): repo = self.cleaned_data.get('repo') if not repo or not is_repo_link(repo) or '/' not in repo[10:]: @@ -1205,7 +1205,7 @@ def clean_repo(self): class SettingsBaseForm(CleanRepoMixin, forms.ModelForm): """Component base form.""" - class Meta(object): + class Meta: model = Component fields = [] @@ -1234,7 +1234,7 @@ def format_value(self, value): class ComponentSettingsForm(SettingsBaseForm): """Component settings form.""" - class Meta(object): + class Meta: model = Component fields = ( 'name', @@ -1365,7 +1365,7 @@ def __init__(self, request, *args, **kwargs): class ComponentCreateForm(SettingsBaseForm): """Component creation form.""" - class Meta(object): + class Meta: model = Component fields = [ 'project', @@ -1608,7 +1608,7 @@ def clean(self): class ComponentRenameForm(SettingsBaseForm): """Component rename form.""" - class Meta(object): + class Meta: model = Component fields = ['slug'] @@ -1616,7 +1616,7 @@ class Meta(object): class ComponentMoveForm(SettingsBaseForm): """Component rename form.""" - class Meta(object): + class Meta: model = Component fields = ['project'] @@ -1628,7 +1628,7 @@ def __init__(self, request, *args, **kwargs): class ProjectSettingsForm(SettingsBaseForm): """Project settings form.""" - class Meta(object): + class Meta: model = Project fields = ( 'name', @@ -1661,7 +1661,7 @@ def __init__(self, request, *args, **kwargs): class ProjectRenameForm(SettingsBaseForm): """Project rename form.""" - class Meta(object): + class Meta: model = Project fields = ['slug'] @@ -1678,7 +1678,7 @@ class ProjectCreateForm(SettingsBaseForm): empty_label=None, ) - class Meta(object): + class Meta: model = Project fields = ('name', 'slug', 'web', 'mail', 'instructions') @@ -1686,7 +1686,7 @@ class Meta(object): class ProjectAccessForm(forms.ModelForm): """Project access control settings form.""" - class Meta(object): + class Meta: model = Project fields = ('access_control', 'enable_review') @@ -1855,7 +1855,7 @@ def clean(self): class WhiteboardForm(forms.ModelForm): """Component base form.""" - class Meta(object): + class Meta: model = WhiteboardMessage fields = ['message', 'category', 'expiry'] widgets = {'expiry': WeblateDateInput()} @@ -1882,7 +1882,7 @@ def __init__(self, request, *args, **kwargs): class LabelForm(forms.ModelForm): - class Meta(object): + class Meta: model = Label fields = ('name', 'color') widgets = {'color': forms.RadioSelect()} diff --git a/weblate/trans/mixins.py b/weblate/trans/mixins.py index 2ff2d04f0fc0..d99b2dde6e61 100644 --- a/weblate/trans/mixins.py +++ b/weblate/trans/mixins.py @@ -28,7 +28,7 @@ from weblate.logger import LOGGER -class URLMixin(object): +class URLMixin: """Mixin for models providing standard shortcut API for few standard URLs.""" _reverse_url_name = None @@ -73,7 +73,7 @@ def get_remove_url(self): return self.reverse_url('remove') -class LoggerMixin(object): +class LoggerMixin: """Mixin for models with logging.""" @cached_property @@ -145,7 +145,7 @@ def create_path(self): os.makedirs(path) -class UserDisplayMixin(object): +class UserDisplayMixin: def get_user_display(self, icon=True): return get_user_display(self.user, icon, link=True) diff --git a/weblate/trans/models/_conf.py b/weblate/trans/models/_conf.py index cfaac5c8e728..5b098691f7b3 100644 --- a/weblate/trans/models/_conf.py +++ b/weblate/trans/models/_conf.py @@ -170,5 +170,5 @@ class WeblateConf(AppConf): LICENSE_REQUIRED = False FONTS_CDN_URL = None - class Meta(object): + class Meta: prefix = '' diff --git a/weblate/trans/models/agreement.py b/weblate/trans/models/agreement.py index 9e16560d7c28..c37f84dac3ff 100644 --- a/weblate/trans/models/agreement.py +++ b/weblate/trans/models/agreement.py @@ -51,7 +51,7 @@ class ContributorAgreement(models.Model): objects = ContributorAgreementManager() - class Meta(object): + class Meta: unique_together = [('user', 'component')] def __str__(self): diff --git a/weblate/trans/models/alert.py b/weblate/trans/models/alert.py index 00748a6d7e36..4631d524f7a8 100644 --- a/weblate/trans/models/alert.py +++ b/weblate/trans/models/alert.py @@ -47,7 +47,7 @@ class Alert(models.Model): name = models.CharField(max_length=150) details = JSONField(default={}) - class Meta(object): + class Meta: unique_together = ('component', 'name') @cached_property @@ -74,7 +74,7 @@ def save(self, *args, **kwargs): ) -class BaseAlert(object): +class BaseAlert: verbose = '' on_import = False link_wide = False diff --git a/weblate/trans/models/change.py b/weblate/trans/models/change.py index 5acd8cda4d6d..fd13fe822ebe 100644 --- a/weblate/trans/models/change.py +++ b/weblate/trans/models/change.py @@ -427,7 +427,7 @@ class Change(models.Model, UserDisplayMixin): objects = ChangeManager.from_queryset(ChangeQuerySet)() - class Meta(object): + class Meta: app_label = 'trans' def __init__(self, *args, **kwargs): diff --git a/weblate/trans/models/comment.py b/weblate/trans/models/comment.py index a34477b8d015..09d5c3092fcf 100644 --- a/weblate/trans/models/comment.py +++ b/weblate/trans/models/comment.py @@ -61,7 +61,7 @@ class Comment(models.Model, UserDisplayMixin): objects = CommentManager.from_queryset(CommentQuerySet)() - class Meta(object): + class Meta: app_label = 'trans' def __str__(self): diff --git a/weblate/trans/models/component.py b/weblate/trans/models/component.py index 7ceb80b8b971..adfb04d7a4df 100644 --- a/weblate/trans/models/component.py +++ b/weblate/trans/models/component.py @@ -496,7 +496,7 @@ class Component(models.Model, URLMixin, PathMixin): is_lockable = True _reverse_url_name = "component" - class Meta(object): + class Meta: unique_together = (("project", "name"), ("project", "slug")) app_label = "trans" verbose_name = gettext_lazy("Component") diff --git a/weblate/trans/models/componentlist.py b/weblate/trans/models/componentlist.py index 33b1ed9434d0..49feb91d28cf 100644 --- a/weblate/trans/models/componentlist.py +++ b/weblate/trans/models/componentlist.py @@ -65,7 +65,7 @@ class ComponentList(models.Model): objects = ComponentListQuerySet.as_manager() - class Meta(object): + class Meta: verbose_name = _('Component list') verbose_name_plural = _('Component lists') @@ -112,6 +112,6 @@ def check_match(self, component): return self.componentlist.components.add(component) - class Meta(object): + class Meta: verbose_name = _('Automatic component list assignment') verbose_name_plural = _('Automatic component list assignments') diff --git a/weblate/trans/models/dictionary.py b/weblate/trans/models/dictionary.py index 02eb7f231506..68898deccf85 100644 --- a/weblate/trans/models/dictionary.py +++ b/weblate/trans/models/dictionary.py @@ -178,7 +178,7 @@ class Dictionary(models.Model): objects = DictionaryManager.from_queryset(DictionaryQuerySet)() - class Meta(object): + class Meta: app_label = 'trans' def __str__(self): diff --git a/weblate/trans/models/label.py b/weblate/trans/models/label.py index e5239642ea3b..9b1f9b5bba9c 100644 --- a/weblate/trans/models/label.py +++ b/weblate/trans/models/label.py @@ -69,7 +69,7 @@ class Label(models.Model): default=None, ) - class Meta(object): + class Meta: app_label = "trans" unique_together = ("project", "name") diff --git a/weblate/trans/models/project.py b/weblate/trans/models/project.py index 459f7c6ad3a5..3c5659ca0fb2 100644 --- a/weblate/trans/models/project.py +++ b/weblate/trans/models/project.py @@ -142,7 +142,7 @@ class Project(models.Model, URLMixin, PathMixin): objects = ProjectQuerySet.as_manager() - class Meta(object): + class Meta: app_label = 'trans' verbose_name = gettext_lazy('Project') verbose_name_plural = gettext_lazy('Projects') diff --git a/weblate/trans/models/shaping.py b/weblate/trans/models/shaping.py index 3354d0bc34f0..4a8c3706a672 100644 --- a/weblate/trans/models/shaping.py +++ b/weblate/trans/models/shaping.py @@ -29,7 +29,7 @@ class Shaping(models.Model): shaping_regex = RegexField(max_length=190) key = models.CharField(max_length=190, db_index=True) - class Meta(object): + class Meta: unique_together = (("key", "component", "shaping_regex"),) def __str__(self): diff --git a/weblate/trans/models/suggestion.py b/weblate/trans/models/suggestion.py index 38f7d5116992..1acbb990d5ca 100644 --- a/weblate/trans/models/suggestion.py +++ b/weblate/trans/models/suggestion.py @@ -110,7 +110,7 @@ class Suggestion(models.Model, UserDisplayMixin): objects = SuggestionManager.from_queryset(SuggestionQuerySet)() - class Meta(object): + class Meta: app_label = 'trans' def __str__(self): @@ -178,7 +178,7 @@ class Vote(models.Model): POSITIVE = 1 NEGATIVE = -1 - class Meta(object): + class Meta: unique_together = ('suggestion', 'user') app_label = 'trans' diff --git a/weblate/trans/models/translation.py b/weblate/trans/models/translation.py index fa305c64d27b..807615c5d216 100644 --- a/weblate/trans/models/translation.py +++ b/weblate/trans/models/translation.py @@ -119,7 +119,7 @@ class Translation(models.Model, URLMixin, LoggerMixin): is_lockable = False _reverse_url_name = 'translation' - class Meta(object): + class Meta: app_label = 'trans' unique_together = ('component', 'language') diff --git a/weblate/trans/models/unit.py b/weblate/trans/models/unit.py index 4a3d3d1e110a..0cafc843ea22 100644 --- a/weblate/trans/models/unit.py +++ b/weblate/trans/models/unit.py @@ -215,7 +215,7 @@ class Unit(models.Model, LoggerMixin): objects = UnitQuerySet.as_manager() - class Meta(object): + class Meta: app_label = 'trans' unique_together = ('translation', 'id_hash') index_together = [('translation', 'pending'), ('priority', 'position')] diff --git a/weblate/trans/models/whiteboard.py b/weblate/trans/models/whiteboard.py index 6963b40f4ff4..f0d683503f16 100644 --- a/weblate/trans/models/whiteboard.py +++ b/weblate/trans/models/whiteboard.py @@ -120,7 +120,7 @@ class WhiteboardMessage(models.Model): objects = WhiteboardManager() - class Meta(object): + class Meta: app_label = 'trans' verbose_name = gettext_lazy('Whiteboard message') verbose_name_plural = gettext_lazy('Whiteboard messages') diff --git a/weblate/trans/tests/test_views.py b/weblate/trans/tests/test_views.py index cdd2224a9fb9..f65495d57c1d 100644 --- a/weblate/trans/tests/test_views.py +++ b/weblate/trans/tests/test_views.py @@ -50,7 +50,7 @@ from weblate.utils.hash import hash_to_checksum -class RegistrationTestMixin(object): +class RegistrationTestMixin: """Helper to share code for registration testing.""" def assert_registration_mailbox(self, match=None): diff --git a/weblate/trans/tests/utils.py b/weblate/trans/tests/utils.py index ab4f39004162..251bcc68027b 100644 --- a/weblate/trans/tests/utils.py +++ b/weblate/trans/tests/utils.py @@ -76,7 +76,7 @@ def create_another_user(): ) -class RepoTestMixin(object): +class RepoTestMixin: """Mixin for testing with test repositories.""" updated_base_repos = set() @@ -377,7 +377,7 @@ def create_link_existing(self): ) -class TempDirMixin(object): +class TempDirMixin: tempdir = None def create_temp(self): diff --git a/weblate/trans/views/guide.py b/weblate/trans/views/guide.py index 4b3a9f73ef03..9e467181aa41 100644 --- a/weblate/trans/views/guide.py +++ b/weblate/trans/views/guide.py @@ -37,7 +37,7 @@ def register(cls): return cls -class Guideline(object): +class Guideline: description = "" group = False url = "" diff --git a/weblate/trans/widgets.py b/weblate/trans/widgets.py index 19e6b83f9e73..f6810f88af38 100644 --- a/weblate/trans/widgets.py +++ b/weblate/trans/widgets.py @@ -57,7 +57,7 @@ def register_widget(widget): return widget -class Widget(object): +class Widget: """Generic widget class.""" name = None diff --git a/weblate/utils/classloader.py b/weblate/utils/classloader.py index ee9de0e0e49d..93978dcd9aa7 100644 --- a/weblate/utils/classloader.py +++ b/weblate/utils/classloader.py @@ -49,7 +49,7 @@ def load_class(name, setting): ) -class ClassLoader(object): +class ClassLoader: """Dict like object to lazy load list of classes.""" def __init__(self, name, construct=True): diff --git a/weblate/utils/forms.py b/weblate/utils/forms.py index 4073ecc22e86..57d353ba6ba1 100644 --- a/weblate/utils/forms.py +++ b/weblate/utils/forms.py @@ -28,7 +28,7 @@ from weblate.trans.util import sort_unicode -class SortedSelectMixin(object): +class SortedSelectMixin: """Mixin for Select widgets to sort choices alphabetically.""" def optgroups(self, name, value, attrs=None): diff --git a/weblate/utils/index.py b/weblate/utils/index.py index 684d10d3393e..b684dc00acd5 100644 --- a/weblate/utils/index.py +++ b/weblate/utils/index.py @@ -30,7 +30,7 @@ from weblate.utils.data import data_dir -class WhooshIndex(object): +class WhooshIndex: """Whoosh index abstraction to ease manipulation.""" LOCATION = 'index' diff --git a/weblate/utils/models.py b/weblate/utils/models.py index 2c5b947ed434..444fac8c6e00 100644 --- a/weblate/utils/models.py +++ b/weblate/utils/models.py @@ -63,7 +63,7 @@ class WeblateConf(AppConf): DATABASE_BACKUP = 'plain' - class Meta(object): + class Meta: prefix = '' diff --git a/weblate/utils/search.py b/weblate/utils/search.py index 0b1eb2c1c305..69b46cc98247 100644 --- a/weblate/utils/search.py +++ b/weblate/utils/search.py @@ -35,7 +35,7 @@ from weblate.utils.state import STATE_NAMES, STATE_TRANSLATED -class Comparer(object): +class Comparer: """String comparer abstraction. The reason is to be able to change implementation. diff --git a/weblate/utils/stats.py b/weblate/utils/stats.py index 0272329d729b..7752c52d5802 100644 --- a/weblate/utils/stats.py +++ b/weblate/utils/stats.py @@ -106,7 +106,7 @@ def prefetch_stats(queryset): return queryset -class ParentStats(object): +class ParentStats: def __init__(self, stats, parent): self.translated_percent = stats.calculate_percents( "translated_percent", parent.source_strings @@ -115,7 +115,7 @@ def __init__(self, stats, parent): self.translated = stats.translated -class BaseStats(object): +class BaseStats: """Caching statistics calculator.""" basic_keys = BASIC_KEYS diff --git a/weblate/utils/views.py b/weblate/utils/views.py index 64c40b3ddfdd..53533dd68de8 100644 --- a/weblate/utils/views.py +++ b/weblate/utils/views.py @@ -62,7 +62,7 @@ def get_paginator(request, object_list, default_page_limit=50): return paginator.page(paginator.num_pages) -class ComponentViewMixin(object): +class ComponentViewMixin: # This should be done in setup once we drop support for older Django def get_component(self): @@ -71,7 +71,7 @@ def get_component(self): ) -class ProjectViewMixin(object): +class ProjectViewMixin: project = None # This should be done in setup once we drop support for older Django diff --git a/weblate/vcs/base.py b/weblate/vcs/base.py index e303d6512543..f0e7d1c85046 100644 --- a/weblate/vcs/base.py +++ b/weblate/vcs/base.py @@ -62,7 +62,7 @@ def __str__(self): return self.get_message() -class Repository(object): +class Repository: """Basic repository object.""" _cmd = 'false' diff --git a/weblate/vcs/models.py b/weblate/vcs/models.py index d3cdc7b3a6cf..33c459c56c55 100644 --- a/weblate/vcs/models.py +++ b/weblate/vcs/models.py @@ -55,5 +55,5 @@ class VCSConf(AppConf): ) CLONE_DEPTH = 1 - class Meta(object): + class Meta: prefix = 'VCS' diff --git a/weblate/vcs/ssh.py b/weblate/vcs/ssh.py index 9c49b55bd98b..62d343e51564 100644 --- a/weblate/vcs/ssh.py +++ b/weblate/vcs/ssh.py @@ -173,7 +173,7 @@ def can_generate_key(): return find_executable('ssh-keygen') is not None -class SSHWrapper(object): +class SSHWrapper: SSH_WRAPPER_TEMPLATE = r'''#!/bin/sh exec ssh \ -o "UserKnownHostsFile={known_hosts}" \ diff --git a/weblate/wladmin/forms.py b/weblate/wladmin/forms.py index 45bba40b1f17..b3628d3d8dcf 100644 --- a/weblate/wladmin/forms.py +++ b/weblate/wladmin/forms.py @@ -61,6 +61,6 @@ class TestMailForm(forms.Form): class BackupForm(forms.ModelForm): - class Meta(object): + class Meta: model = BackupService fields = ('repository',) diff --git a/weblate/wladmin/models.py b/weblate/wladmin/models.py index 1cef18e9499c..ca380b28ff67 100644 --- a/weblate/wladmin/models.py +++ b/weblate/wladmin/models.py @@ -77,7 +77,7 @@ class ConfigurationError(models.Model): objects = ConfigurationErrorManager() - class Meta(object): + class Meta: index_together = [('ignored', 'timestamp')] def __str__(self):