Skip to content

Commit

Permalink
Fix flake8 warnings F405
Browse files Browse the repository at this point in the history
  • Loading branch information
UlrichB22 committed Jul 10, 2022
1 parent 669052a commit bbc37bb
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 15 deletions.
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ minversion = 2.0
# flake8 failures that appear with your change.
ignore =
E501, # line too long
F405, # 'name' may be undefined, or defined from star imports
W504, # line break after binary operator
# line length long term target: 120
max-line-length = 255
per-file-ignores =
src/moin/apps/frontend/views.py:F405
src/moin/scripts/migration/moin19/import19.py:F405
src/moin/storage/middleware/indexing.py:F405
exclude =
build, dist, .git, .idea, .cache, .tox, .eggs,
docs/conf.py, # sphinx stuff, automatically generated, don't check this
Expand Down
2 changes: 1 addition & 1 deletion src/moin/auth/_tests/test_ldap_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


from moin._tests.ldap_testbase import LDAPTstBase, LdapEnvironment, check_environ, SLAPD_EXECUTABLE
from moin._tests.ldap_testdata import * # noqa
from moin._tests.ldap_testdata import BASEDN, LDIF_CONTENT, ROOTDN, ROOTPW, SLAPD_CONFIG
from moin._tests import wikiconfig
from moin.auth import handle_login

Expand Down
21 changes: 16 additions & 5 deletions src/moin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
from flask import current_app as app
from flask import flash

from moin.constants.forms import * # noqa
from moin.constants.forms import (
WIDGET_ANY_INTEGER, WIDGET_CHECKBOX, WIDGET_DATETIME, WIDGET_EMAIL, WIDGET_FILE, WIDGET_HIDDEN,
WIDGET_INLINE_CHECKBOX, WIDGET_MULTILINE_TEXT, WIDGET_MULTI_SELECT, WIDGET_PASSWORD, WIDGET_RADIO_CHOICE,
WIDGET_READONLY_ITEM_LINK_LIST, WIDGET_READONLY_STRING_LIST, WIDGET_SEARCH, WIDGET_SELECT,
WIDGET_SELECT_SUBMIT, WIDGET_SMALL_NATURAL, WIDGET_TEXT
)

from moin.constants.keys import ITEMID, NAME, LATEST_REVS, NAMESPACE, FQNAME
from moin.constants.namespaces import NAMESPACES_IDENTIFIER
from moin.i18n import _, L_
Expand Down Expand Up @@ -102,22 +108,26 @@ def validate_name(meta, itemid):
# Item names must not start with '@' or '+', '@something' denotes a field where as '+something' denotes a view.
invalid_names = [name for name in names if name.startswith(('@', '+'))]
if invalid_names:
msg = L_("Item names (%(invalid_names)s) must not start with '@' or '+'", invalid_names=", ".join(invalid_names))
msg = L_("Item names (%(invalid_names)s) must not start with '@' or '+'",
invalid_names=", ".join(invalid_names))
flash(msg, "error")
raise NameNotValidError(msg)

# Item names must not contain commas
invalid_names = [name for name in names if ',' in name]
if invalid_names:
msg = L_("Item name (%(invalid_names)s) must not contain ',' characters. Create item with 1 name, use rename to create multiple names.", invalid_names=", ".join(invalid_names))
msg = L_("Item name (%(invalid_names)s) must not contain ',' characters. "
"Create item with 1 name, use rename to create multiple names.",
invalid_names=", ".join(invalid_names))
flash(msg, "error")
raise NameNotValidError(msg)

namespaces = namespaces + NAMESPACES_IDENTIFIER # Also dont allow item names to match with identifier namespaces.
# Item names must not match with existing namespaces.
invalid_names = [name for name in names if name.split('/', 1)[0] in namespaces]
if invalid_names:
msg = L_("Item names (%(invalid_names)s) must not match with existing namespaces.", invalid_names=", ".join(invalid_names))
msg = L_("Item names (%(invalid_names)s) must not match with existing namespaces.",
invalid_names=", ".join(invalid_names))
flash(msg, "error") # duplicate message at top of form
raise NameNotValidError(msg)
query = And([Or([Term(NAME, name) for name in names]), Term(NAMESPACE, current_namespace)])
Expand All @@ -140,7 +150,8 @@ class ValidName(Validator):

def validate(self, element, state):
if state is None:
# incoming request is from +usersettings#personal; apps/frontend/views.py will validate changes to user names
# incoming request is from +usersettings#personal;
# apps/frontend/views.py will validate changes to user names
return True
try:
validate_name(state['meta'], state[ITEMID])
Expand Down
11 changes: 7 additions & 4 deletions src/moin/items/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
from moin.items import Item, Contentful, register, BaseModifyForm, get_itemtype_specific_tags, IndexEntry
from moin.items.content import NonExistentContent
from moin.utils.interwiki import CompositeName
from moin.constants.forms import * # noqa
from moin.constants.forms import WIDGET_SEARCH

USER_QUERY = Term(CONTENTTYPE, CONTENTTYPE_USER)
TICKET_QUERY = Term(ITEMTYPE, ITEMTYPE_TICKET)
Expand Down Expand Up @@ -94,7 +94,8 @@ def get_name(rev):

class AdvancedSearchForm(Form):
q = Search
summary = Text.using(label=L_("Summary"), optional=False).with_properties(widget=WIDGET_SEARCH, placeholder=L_("Find Tickets"))
summary = Text.using(label=L_("Summary"),
optional=False).with_properties(widget=WIDGET_SEARCH, placeholder=L_("Find Tickets"))
effort = Rating.using(label=L_("Effort"))
difficulty = Rating.using(label=L_("Difficulty"))
severity = Rating.using(label=L_("Severity"))
Expand All @@ -105,7 +106,8 @@ class AdvancedSearchForm(Form):


class TicketMetaForm(Form):
summary = Text.using(label=L_("Summary"), optional=False).with_properties(widget=WIDGET_SEARCH, placeholder=L_("One-line summary"))
summary = Text.using(label=L_("Summary"),
optional=False).with_properties(widget=WIDGET_SEARCH, placeholder=L_("One-line summary"))
effort = Rating.using(label=L_("Effort"))
difficulty = Rating.using(label=L_("Difficulty"))
severity = Rating.using(label=L_("Severity"))
Expand Down Expand Up @@ -370,7 +372,8 @@ def do_modify(self):
elif request.method == 'POST':
form = Form.from_request(request)
if form.validate():
meta, data, message, data_file = form._dump(self) # saves new ticket revision if ticket meta has changed
# save new ticket revision if ticket meta has changed
meta, data, message, data_file = form._dump(self)
try:
if not is_new and message:
# user created a new comment
Expand Down
2 changes: 1 addition & 1 deletion src/moin/signalling/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""


from .signals import * # noqa
from .signals import ANY, item_displayed, item_modified
from flask import got_request_exception

from .. import log
Expand Down
6 changes: 5 additions & 1 deletion src/moin/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
from moin import wikiutil
from moin.constants.contenttypes import CONTENTTYPE_USER
from moin.constants.namespaces import NAMESPACE_USERPROFILES
from moin.constants.keys import * # noqa
from moin.constants.keys import (
BOOKMARKS, CONTENTTYPE, CURRENT, DISABLED, EMAIL, EMAIL_UNVALIDATED, ENC_PASSWORD, ITEMID, NAME, NAME_EXACT,
NAMEPREFIX, NAMERE, NAMESPACE, RECOVERPASS_KEY, SESSION_KEY, SESSION_TOKEN, TAGS, USEROBJ_ATTRS, WIKINAME
)

from moin.constants.misc import ANON
from moin.i18n import _
from moin.mail import sendmail
Expand Down
2 changes: 1 addition & 1 deletion src/moin/utils/_tests/test_mime.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""


from moin.utils.mime import * # noqa
from moin.utils.mime import Type


def test_Type_init_1():
Expand Down
2 changes: 1 addition & 1 deletion src/moin/utils/rev_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from flask import current_app as app
from flask import request
from whoosh.query import Term, And
from moin.constants.keys import * # noqa
from moin.constants.keys import ALL_REVS, CURRENT, MTIME, WIKINAME


def prior_next_revs(revid, fqname):
Expand Down

0 comments on commit bbc37bb

Please sign in to comment.