Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ericof committed Jul 15, 2024
1 parent 7c9007d commit 2dde588
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 32 deletions.
11 changes: 2 additions & 9 deletions backend/scripts/create_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from collective.volto.formsupport.interfaces import ICollectiveVoltoFormsupportLayer
from Products.CMFPlone.factory import _DEFAULT_PROFILE
from Products.CMFPlone.factory import addPloneSite
from Products.GenericSetup.tool import SetupTool
from Testing.makerequest import makerequest
from zope.interface import directlyProvidedBy
from zope.interface import directlyProvides
Expand Down Expand Up @@ -35,7 +34,7 @@ def asbool(s):

request = app.REQUEST

ifaces = [ICollectiveVoltoFormsupportLayer] + list(directlyProvidedBy(request))
ifaces = [ICollectiveVoltoFormsupportLayer] + list(directlyProvidedBy(request)) # noQA: RUF005

directlyProvides(request, *ifaces)

Expand All @@ -50,7 +49,7 @@ def asbool(s):
"extension_ids": [
"collective.volto.formsupport:default",
],
"setup_content": False,
"setup_content": bool(EXAMPLE_CONTENT),
"default_language": "en",
"portal_timezone": "UTC",
}
Expand All @@ -63,10 +62,4 @@ def asbool(s):
if site_id not in app.objectIds():
site = addPloneSite(app, site_id, **payload)
transaction.commit()
if EXAMPLE_CONTENT:
portal_setup: SetupTool = site.portal_setup
portal_setup.runAllImportStepsFromProfile(
"collective.volto.formsupport:initial"
)
transaction.commit()
app._p_jar.sync()
4 changes: 2 additions & 2 deletions backend/src/collective/volto/formsupport/captcha/norobots.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def verify(self, data):
context=self.context, request=self.request, name="norobots"
)
value = json_token.get("value")
id = json_token.get("id")
id_ = json_token.get("id")
id_check = json_token.get("id_check")

if not view.verify(input=value, question_id=id, id_check=id_check):
if not view.verify(input=value, question_id=id_, id_check=id_check):
raise BadRequest(
translate(
_("The code you entered was wrong, please enter the new one."),
Expand Down
10 changes: 5 additions & 5 deletions backend/src/collective/volto/formsupport/datamanager/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def get_form_fields(self):
if not blocks:
return {}
form_block = {}
for id, block in blocks.items():
if id != self.block_id:
for id_, block in blocks.items():
if id_ != self.block_id:
continue
block_type = block.get("@type", "")
if block_type == "form":
Expand Down Expand Up @@ -98,7 +98,7 @@ def add(self, data):
return self.soup.add(record)

def length(self):
return len([x for x in self.soup.data.values()])
return len([x for x in self.soup.data.values()]) # noQA: C416

def search(self, query=None):
if not query:
Expand All @@ -109,8 +109,8 @@ def search(self, query=None):
)
return records

def delete(self, id):
record = self.soup.get(id)
def delete(self, id_):
record = self.soup.get(id_)
del self.soup[record]

def clear(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, context, request):
blocks = getattr(context, "blocks", {})
if not blocks:
return
for id, block in blocks.items():
for _id, block in blocks.items():
block_type = block.get("@type", "")
if block_type == "form":
self.form_block = block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def form_block(self):
blocks = json.loads(blocks)
if not blocks:
return {}
for id, block in blocks.items():
for id_, block in blocks.items():
if block.get("@type", "") == "form" and block.get("store", False):
if not self.block_id or self.block_id == id:
if not self.block_id or self.block_id == id_:
return block
return {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def reply(self):
context=self.request,
)
self.request.response.setStatus(500)
return dict(type="InternalServerError", message=message)
return {
"type": "InternalServerError",
"message": message
}
if store_action:
self.store_data()

Expand Down Expand Up @@ -258,8 +261,8 @@ def get_block_data(self, block_id):
blocks = get_blocks(self.context)
if not blocks:
return {}
for id, block in blocks.items():
if id != block_id:
for id_, block in blocks.items():
if id_ != block_id:
continue
block_type = block.get("@type", "")
if block_type != "form":
Expand Down Expand Up @@ -338,7 +341,7 @@ def get_subject(self):

return subject

def send_data(self):
def send_data(self): # noQA: C901
subject = self.get_subject()

mfrom = self.form_data.get("from", "") or self.block.get("default_from", "")
Expand Down Expand Up @@ -484,7 +487,7 @@ def manage_attachments(self, msg):

if not attachments:
return []
for key, value in attachments.items():
for _key, value in attachments.items():
content_type = "application/octet-stream"
filename = None
if isinstance(value, dict):
Expand Down
8 changes: 4 additions & 4 deletions backend/src/collective/volto/formsupport/scripts/cleansing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

@click.command(
help="bin/instance -OPlone run bin/formsupport_data_cleansing [--dryrun|--no-dryrun]", # noqa: E501
context_settings=dict(
ignore_unknown_options=True,
allow_extra_args=True,
),
context_settings={
"ignore_unknown_options": True,
"allow_extra_args": True,
},
)
@click.option(
"--dryrun/--no-dryrun",
Expand Down
5 changes: 1 addition & 4 deletions backend/src/collective/volto/formsupport/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@


def _has_block_form(block_data):
for block in block_data.values():
if block.get("@type", "") == "form":
return True
return False
return any(block.get("@type", "") == "form" for block in block_data.values())


def _get_all_content_with_blocks():
Expand Down

0 comments on commit 2dde588

Please sign in to comment.