Skip to content

Commit

Permalink
Add codespell to pre-commit and setup.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Apr 12, 2022
1 parent 1849fa0 commit 838fd77
Show file tree
Hide file tree
Showing 33 changed files with 138 additions and 131 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -11,6 +11,11 @@ repos:
- id: django-upgrade
args: [--target-version, "2.2"]

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell # See setup.cfg for args

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
Expand Down
8 changes: 4 additions & 4 deletions cms/cms_menus.py
Expand Up @@ -82,7 +82,7 @@ def get_menu_node_for_page(renderer, page, language, fallbacks=None):
if fallbacks is None:
fallbacks = []

# Theses are simple to port over, since they are not calculated.
# These are simple to port over, since they are not calculated.
# Other attributes will be added conditionally later.
attr = {
'is_page': True,
Expand All @@ -103,8 +103,8 @@ def get_menu_node_for_page(renderer, page, language, fallbacks=None):
if page.navigation_extenders:
if page.navigation_extenders in renderer.menus:
extenders.append(page.navigation_extenders)
elif "{0}:{1}".format(page.navigation_extenders, page.pk) in renderer.menus:
extenders.append("{0}:{1}".format(page.navigation_extenders, page.pk))
elif f"{page.navigation_extenders}:{page.pk}" in renderer.menus:
extenders.append(f"{page.navigation_extenders}:{page.pk}")
# Is this page an apphook? If so, we need to handle the apphooks's nodes
# Only run this if we have a translation in the requested language for this
# object. The title cache should have been prepopulated in CMSMenu.get_nodes
Expand All @@ -120,7 +120,7 @@ def get_menu_node_for_page(renderer, page, language, fallbacks=None):
if hasattr(ext, "get_instances"):
# CMSAttachMenus are treated a bit differently to allow them to be
# able to be attached to multiple points in the navigation.
exts.append("{0}:{1}".format(ext.__name__, page.pk))
exts.append(f"{ext.__name__}:{page.pk}")
elif hasattr(ext, '__name__'):
exts.append(ext.__name__)
else:
Expand Down
18 changes: 9 additions & 9 deletions cms/models/pluginmodel.py
Expand Up @@ -35,7 +35,7 @@ class PluginModelBase(ModelBase):
"""

def __new__(cls, name, bases, attrs):
super_new = super(PluginModelBase, cls).__new__
super_new = super().__new__
# remove RenderMeta from the plugin class
attr_meta = attrs.pop('RenderMeta', None)

Expand Down Expand Up @@ -237,14 +237,14 @@ def get_instance_icon_src(self):
Get src URL for instance's icon
"""
instance, plugin = self.get_plugin_instance()
return plugin.icon_src(instance) if instance else u''
return plugin.icon_src(instance) if instance else ''

def get_instance_icon_alt(self):
"""
Get alt text for instance's icon
"""
instance, plugin = self.get_plugin_instance()
return force_str(plugin.icon_alt(instance)) if instance else u''
return force_str(plugin.icon_alt(instance)) if instance else ''

def update(self, refresh=False, **fields):
CMSPlugin.objects.filter(pk=self.pk).update(**fields)
Expand Down Expand Up @@ -356,7 +356,7 @@ def fix_tree(cls, destructive=False):
"""
from cms.utils.plugins import reorder_plugins

super(CMSPlugin, cls).fix_tree(destructive)
super().fix_tree(destructive)
for placeholder in Placeholder.objects.all():
for language, __ in settings.LANGUAGES:
order = CMSPlugin.objects.filter(
Expand Down Expand Up @@ -421,29 +421,29 @@ def get_breadcrumb(self):
try:
url = force_str(
admin_reverse(
"%s_%s_edit_plugin" % (model._meta.app_label, model._meta.model_name),
f"{model._meta.app_label}_{model._meta.model_name}_edit_plugin",
args=[parent.pk]
)
)
except NoReverseMatch:
url = force_str(
admin_reverse(
"%s_%s_edit_plugin" % (Page._meta.app_label, Page._meta.model_name),
f"{Page._meta.app_label}_{Page._meta.model_name}_edit_plugin",
args=[parent.pk]
)
)
breadcrumb.append({'title': force_str(parent.get_plugin_name()), 'url': url})
try:
url = force_str(
admin_reverse(
"%s_%s_edit_plugin" % (model._meta.app_label, model._meta.model_name),
f"{model._meta.app_label}_{model._meta.model_name}_edit_plugin",
args=[self.pk]
)
)
except NoReverseMatch:
url = force_str(
admin_reverse(
"%s_%s_edit_plugin" % (Page._meta.app_label, Page._meta.model_name),
f"{Page._meta.app_label}_{Page._meta.model_name}_edit_plugin",
args=[self.pk]
)
)
Expand Down Expand Up @@ -526,7 +526,7 @@ def get_plugin_media_path(instance, filename):
Django requires that unbound function used in fields' definitions to be
defined outside the parent class.
(see https://docs.djangoproject.com/en/dev/topics/migrations/#serializing-values)
This function is used withing field definition:
This function is used within field definition:
file = models.FileField(_("file"), upload_to=get_plugin_media_path)
Expand Down
2 changes: 1 addition & 1 deletion cms/static/cms/sass/components/_general.scss
Expand Up @@ -10,7 +10,7 @@
width: 100%;
}

// other styles that might be used by components accross the components
// other styles that might be used by components across the components
.cms-prevent-scrolling {
overflow: hidden !important;
body {
Expand Down
2 changes: 1 addition & 1 deletion cms/static/cms/sass/components/_sideframe.scss
Expand Up @@ -42,7 +42,7 @@
}
}

// when resizing the sideframe shime get's z-index between frame
// when resizing the sideframe shim gets z-index between frame
// and resize in order for mouse events not to trigger on iframe, same as
// with modal
.cms-sideframe-shim {
Expand Down
2 changes: 1 addition & 1 deletion cms/static/cms/sass/components/pagetree/_tree.scss
Expand Up @@ -668,7 +668,7 @@
// parent and children ul
.jstree-container-ul,
.jstree-children,
// children and childrens children li
// children and children's children li
.jstree-leaf,
.jstree-node {
list-style-type: none;
Expand Down
2 changes: 1 addition & 1 deletion cms/static/cms/sass/mixins/_zindex.scss
@@ -1,7 +1,7 @@
// #############################################################################
// ZINDEX

// handle z-index mor easily
// handle z-index more easily
// DOCS: http://www.sitepoint.com/better-solution-managing-z-index-sass/
// http://sassmeister.com/gist/341c052928c956c1a751
// use case: header { z-index: z("modal", "header"); }
Expand Down
2 changes: 1 addition & 1 deletion cms/static/cms/sass/settings/_cms.scss
Expand Up @@ -147,7 +147,7 @@ $z-layers: (
"fixed-headers": 2,
"container": 1,
),
// parent dependant, but should be higher than quicksearch, but
// parent dependent, but should be higher than quicksearch, but
// lower than dropdown
"hovertooltip": 1001,
"screenblock": 100,
Expand Down
2 changes: 1 addition & 1 deletion cms/templates/cms/toolbar/toolbar_javascript.html
Expand Up @@ -28,7 +28,7 @@
'debug': '{% filter escapejs %}{% blocktrans %}Development version using django CMS {{ cms_version }}, Django {{ django_version }}, Python {{ python_version }}{% endblocktrans %}{% endfilter %}',
{% endif %}
'cancel': '{% filter escapejs %}{% trans "Cancel" %}{% endfilter %}',
'error': '<strong>{% filter escapejs %}{% trans "The following error occured:" %}{% endfilter %}</strong> ',
'error': '<strong>{% filter escapejs %}{% trans "The following error occurred:" %}{% endfilter %}</strong> ',
'success': '{% filter escapejs %}{% trans "Action successful." %}{% endfilter %}',
'confirm': '{% filter escapejs %}{% trans "Are you sure you want to delete this plugin?" %}{% endfilter %}',
'publish': '{% filter escapejs %}{% trans "Are you sure you want to publish this page?" %}{% endfilter %}',
Expand Down
20 changes: 10 additions & 10 deletions cms/templatetags/cms_tags.py
Expand Up @@ -492,7 +492,7 @@ def render_tag(self, context, **kwargs):
def _get_editable_context(self, context, instance, language, edit_fields,
view_method, view_url, querystring, editmode=True):
"""
Populate the contex with the requested attributes to trigger the changeform
Populate the context with the requested attributes to trigger the changeform
"""
request = context['request']
if hasattr(request, 'toolbar'):
Expand All @@ -508,16 +508,16 @@ def _get_editable_context(self, context, instance, language, edit_fields,
with force_language(lang):
extra_context = {}
if edit_fields == 'changelist':
instance.get_plugin_name = "%s %s list" % (smart_str(_('Edit')), smart_str(opts.verbose_name))
instance.get_plugin_name = "{} {} list".format(smart_str(_('Edit')), smart_str(opts.verbose_name))
extra_context['attribute_name'] = 'changelist'
elif editmode:
instance.get_plugin_name = "%s %s" % (smart_str(_('Edit')), smart_str(opts.verbose_name))
instance.get_plugin_name = "{} {}".format(smart_str(_('Edit')), smart_str(opts.verbose_name))
if not context.get('attribute_name', None):
# Make sure CMS.Plugin object will not clash in the frontend.
extra_context['attribute_name'] = '-'.join(edit_fields) \
if not isinstance('edit_fields', str) else edit_fields
else:
instance.get_plugin_name = "%s %s" % (smart_str(_('Add')), smart_str(opts.verbose_name))
instance.get_plugin_name = "{} {}".format(smart_str(_('Add')), smart_str(opts.verbose_name))
extra_context['attribute_name'] = 'add'
extra_context['instance'] = instance
extra_context['generic'] = opts
Expand All @@ -535,28 +535,28 @@ def _get_editable_context(self, context, instance, language, edit_fields,
# The default view_url is the default admin changeform for the
# current instance
if not editmode:
view_url = 'admin:%s_%s_add' % (
view_url = 'admin:{}_{}_add'.format(
opts.app_label, opts.model_name)
url_base = reverse(view_url)
elif not edit_fields:
if not view_url:
view_url = 'admin:%s_%s_change' % (
view_url = 'admin:{}_{}_change'.format(
opts.app_label, opts.model_name)
if isinstance(instance, Page):
url_base = reverse(view_url, args=(instance.pk, language))
else:
url_base = reverse(view_url, args=(instance.pk,))
else:
if not view_url:
view_url = 'admin:%s_%s_edit_field' % (
view_url = 'admin:{}_{}_edit_field'.format(
opts.app_label, opts.model_name)
if view_url.endswith('_changelist'):
url_base = reverse(view_url)
else:
url_base = reverse(view_url, args=(instance.pk, language))
querystring['edit_fields'] = ",".join(context['edit_fields'])
if editmode:
extra_context['edit_url'] = "%s?%s" % (url_base, urlencode(querystring))
extra_context['edit_url'] = f"{url_base}?{urlencode(querystring)}"
else:
extra_context['edit_url'] = "%s" % url_base
extra_context['refresh_page'] = True
Expand Down Expand Up @@ -654,13 +654,13 @@ def _get_empty_context(self, context, instance, edit_fields, language,
edit_fields = 'title,page_title,menu_title'
view_url = 'admin:cms_page_edit_title_fields'
if edit_fields == 'changelist':
view_url = 'admin:%s_%s_changelist' % (
view_url = 'admin:{}_{}_changelist'.format(
instance._meta.app_label, instance._meta.model_name)
querystring = OrderedDict((('language', language),))
if edit_fields:
extra_context['edit_fields'] = edit_fields.strip().split(",")
# If the toolbar is not enabled the following part is just skipped: it
# would cause a perfomance hit for no reason
# would cause a performance hit for no reason
if self._is_editable(context.get('request', None)):
extra_context.update(self._get_editable_context(
extra_context, instance, language, edit_fields, view_method,
Expand Down
2 changes: 1 addition & 1 deletion cms/test_utils/project/emailuserapp/forms.py
Expand Up @@ -105,6 +105,6 @@ def clean_password(self):
"""
Regardless of what the user provides, return the initial value.
This is done here, rather than on the field, because the
field does not have access to the inital value.
field does not have access to the initial value.
"""
return self.initial["password"]
3 changes: 1 addition & 2 deletions cms/test_utils/project/mti_pluginapp/models.py
@@ -1,4 +1,3 @@

from django.db import models

from cms.models import CMSPlugin
Expand Down Expand Up @@ -41,7 +40,7 @@ class Meta:
class TestPluginBetaModel(TestPluginAlphaModel):
"""
NOTE: This is the subject of our test. A plugin which inherits from
another concrete plugin via MTI or Multi-Table Inheritence.
another concrete plugin via MTI or Multi-Table Inheritance.
"""
beta = models.CharField('name', blank=False, default='test plugin beta', max_length=32)

Expand Down
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import itertools

from cms.plugin_base import CMSPluginBase
Expand All @@ -16,7 +15,7 @@ class DynamicJsLoadingPlugin(CMSPluginBase):
def render(self, context, instance, placeholder):
"""
This generates a list of all 16 class usage permutations.
originaly from https://stackoverflow.com/a/54059999
originally from https://stackoverflow.com/a/54059999
>>> import itertools
>>> l=[False,True]
>>> list(itertools.product(l,repeat=4))
Expand Down Expand Up @@ -45,7 +44,7 @@ def render(self, context, instance, placeholder):
*case_list[instance.testcase - 1]
)

return super(DynamicJsLoadingPlugin, self).render(
return super().render(
context, instance, placeholder
)

Expand Down
4 changes: 2 additions & 2 deletions cms/test_utils/project/sampleapp/cms_apps.py
Expand Up @@ -47,7 +47,7 @@ def get_config(self, namespace):
return None

def get_config_add_url(self):
return reverse('admin:%s_%s_add' % (self.app_config._meta.app_label, self.app_config._meta.model_name))
return reverse(f'admin:{self.app_config._meta.app_label}_{self.app_config._meta.model_name}_add')


class SampleAppWithExcludedPermissions(CMSApp):
Expand All @@ -70,7 +70,7 @@ def get_urls(self, page=None, language=None, **kwargs):


class SampleApp3(CMSApp):
# CMSApp which returns the url directly rather than trough another Python module
# CMSApp which returns the url directly rather than through another Python module
name = _("Sample App 3")

def get_urls(self, page=None, language=None, **kwargs):
Expand Down
Expand Up @@ -2,7 +2,7 @@
{% load cms_tags %}

{% comment %}
This files hould result in following placeholders:
This file should result in following placeholders:

- new_one (from this)
- two (from base.html)
Expand Down
Expand Up @@ -2,7 +2,7 @@
{% load cms_tags %}

{% comment %}
This files hould result in following placeholders:
This file should result in following placeholders:

- new_one (from this)
- two (from base.html)
Expand Down
Expand Up @@ -3,7 +3,7 @@
{% load cms_tags %}

{% comment %}
This files hould result in following placeholders:
This file should result in following placeholders:

- new_one (from this)
- two (from base.html)
Expand Down
Expand Up @@ -3,7 +3,7 @@
{% load cms_tags %}

{% comment %}
This files hould result in following placeholders:
This file should result in following placeholders:

- new_one (from this)
- two (from base.html)
Expand Down
Expand Up @@ -3,7 +3,7 @@
{% load cms_tags %}

{% comment %}
This files hould result in following placeholders:
This file should result in following placeholders:

- child (from child.html)
- three (from base.html)
Expand Down
2 changes: 1 addition & 1 deletion cms/test_utils/util/context_managers.py
Expand Up @@ -62,7 +62,7 @@ class TemporaryDirectory:
with TemporaryDirectory() as tmpdir:
...
Upon exiting the context, the directory and everthing contained
Upon exiting the context, the directory and everything contained
in it are removed.
"""

Expand Down

0 comments on commit 838fd77

Please sign in to comment.