Skip to content

Commit

Permalink
style: fix flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jerivas committed Sep 9, 2020
1 parent 1ae2b1b commit 433cee9
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 27 deletions.
10 changes: 6 additions & 4 deletions docs/docs_settings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# flake8: noqa

"""
This is the local_settings file for Mezzanine's docs.
"""

from mezzanine.project_template.project_name.settings import * # noqa
from random import choice

from mezzanine.project_template.project_name.settings import *

DEBUG = False
ROOT_URLCONF = "mezzanine.project_template.project_name.urls"

# Generate a SECRET_KEY for this build
from random import choice

characters = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)"
# Generate a SECRET_KEY for this build
SECRET_KEY = "".join([choice(characters) for i in range(50)])

if "mezzanine.accounts" not in INSTALLED_APPS:
Expand Down
2 changes: 1 addition & 1 deletion mezzanine/blog/management/commands/import_posterous.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def request(self, path, data=None):
try:
response = json.loads(r.text)
return response
except:
except: # noqa
raise CommandError(r.text)

def handle_import(self, options):
Expand Down
8 changes: 4 additions & 4 deletions mezzanine/blog/management/commands/import_rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def handle_import(self, options):
from BeautifulSoup import BeautifulSoup
except ImportError:
raise CommandError("BeautifulSoup package is required")
for l in BeautifulSoup(urlopen(page_url).read()).findAll("link"):
if "application/rss" in l.get(
for link in BeautifulSoup(urlopen(page_url).read()).findAll("link"):
if "application/rss" in link.get(
"type", ""
) or "application/atom" in l.get("type", ""):
rss_url = urljoin(page_url, l["href"])
) or "application/atom" in link.get("type", ""):
rss_url = urljoin(page_url, link["href"])
break
else:
raise CommandError("Could not parse RSS link from the page")
Expand Down
2 changes: 1 addition & 1 deletion mezzanine/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def __delattr__(self, item):
else:
try:
import_module("%s.defaults" % app)
except:
except: # noqa
if module_has_submodule(module, "defaults"):
raise

Expand Down
4 changes: 2 additions & 2 deletions mezzanine/conf/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, *args, **kwargs):
for code in OrderedDict(settings.LANGUAGES):
try:
activate(code)
except:
except: # noqa
pass
else:
self._init_field(
Expand Down Expand Up @@ -126,7 +126,7 @@ def save(self):
if registry[name]["translatable"]:
try:
activate(code)
except:
except: # noqa
pass
finally:
setting_obj.value = value
Expand Down
2 changes: 1 addition & 1 deletion mezzanine/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def save_model(self, request, obj, form, change):
if code != lang: # Already done
try:
activate(code)
except:
except: # noqa
pass
else:
obj.save()
Expand Down
2 changes: 1 addition & 1 deletion mezzanine/core/management/commands/runserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def inner_run(self, *args, **kwargs):
# shouldn't be able to crash the development server.
try:
self.stdout.write(banner())
except:
except: # noqa
pass
super(Command, self).inner_run(*args, **kwargs)

Expand Down
6 changes: 3 additions & 3 deletions mezzanine/core/templatetags/mezzanine_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def thumbnail(
f = default_storage.open(image_url)
try:
image = Image.open(f)
except:
except: # noqa
# Invalid image format.
return image_url

Expand All @@ -386,7 +386,7 @@ def thumbnail(
# - http://caniuse.com/#feat=css-image-orientation
try:
orientation = image._getexif().get(0x0112)
except:
except: # noqa
orientation = None
if orientation:
methods = {
Expand Down Expand Up @@ -420,7 +420,7 @@ def thumbnail(
if image.mode not in ("P", "L", "RGBA") and filetype not in ("JPG", "JPEG"):
try:
image = image.convert("RGBA")
except:
except: # noqa
return image_url
# Required for progressive jpgs.
ImageFile.MAXBLOCK = 2 * (max(image.size) ** 2)
Expand Down
2 changes: 1 addition & 1 deletion mezzanine/galleries/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def save(self, delete_zip_import=True, *args, **kwargs):
image.verify()
except ImportError:
pass
except:
except: # noqa
continue
name = os.path.split(name)[1]

Expand Down
2 changes: 1 addition & 1 deletion mezzanine/pages/page_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ def autodiscover():
else:
try:
import_module("%s.page_processors" % app)
except:
except: # noqa
if module_has_submodule(module, "page_processors"):
raise
2 changes: 1 addition & 1 deletion mezzanine/project_template/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def python(code, show=True):
"import django;"
"django.setup();" % env.proj_app
)
full_code = 'python -c "%s%s"' % (setup, code.replace("`", "\\\`"))
full_code = 'python -c "%s%s"' % (setup, code.replace("`", "\\\`")) # noqa
with project():
if show:
print_command(code)
Expand Down
2 changes: 1 addition & 1 deletion mezzanine/twitter/management/commands/poll_twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ def handle(self, **options):
print("Twitter query error [%s]: %s" % (query, e))
try:
db.close_connection()
except:
except: # noqa
pass
2 changes: 1 addition & 1 deletion mezzanine/utils/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def build_changelog(docs_path, package_name="mezzanine"):
try:
tag(ui, repo, version_tag, rev=cs.hex())
print("Tagging version %s" % version_tag)
except:
except: # noqa
pass

# Ignore changesets that are merges, bumped the version, closed
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import sys

import django
import pytest

from pathlib import Path

Expand Down
4 changes: 2 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def test_multisite(self):
# setup
try:
old_site_id = settings.SITE_ID
except:
except: # noqa
old_site_id = None

site1 = Site.objects.create(domain="site1.com")
Expand Down Expand Up @@ -509,7 +509,7 @@ def test_update_site(self):
# setup
try:
old_site_id = settings.SITE_ID
except:
except: # noqa
old_site_id = None

site1 = Site.objects.create(domain="site1.com")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_submit_button_text(self):
for c in code_list:
try:
activate(c)
except:
except: # noqa
pass
else:
break
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def test_page_slug_has_correct_lang(self):
for code in code_list:
try:
activate(code)
except:
except: # noqa
pass
else:
break
Expand Down

0 comments on commit 433cee9

Please sign in to comment.