Skip to content

Commit

Permalink
refact: fix some ruff warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfermigier committed Nov 5, 2024
1 parent dbd5592 commit 580e79c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
3 changes: 0 additions & 3 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,9 @@ lint.extend-ignore = [
#
"PD011", # Use `.to_numpy()` instead of `.values`
"PERF203", # `try`-`except` within a loop incurs performance overhead
"PERF401", # Use a list comprehension to create a transformed list
"PERF403", # Use a dictionary comprehension instead of a for-loop
"PLC0206", # Extracting value from dictionary without calling `.items()`
"PLC0415", # `import` should be at the top-level of a file
"PLC1901", # `x == ""` can be simplified to `not x` as an empty string is falsey
"PLC2701", # Private name import `_...` from external module
"PLC2801", # Unnecessary dunder call
"PLR0904", # Too many public methods (22 > 20)
"PLR0911", # Too many return statements
Expand Down
4 changes: 2 additions & 2 deletions src/abilian/sbe/apps/forum/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
def inject_email(filename="-"):
"""Read one email from stdin, parse it, forward it in a task to be
persisted."""
_inject_email(filename)
do_inject_email(filename)


def _inject_email(filename="-"):
def do_inject_email(filename="-"):
parser = FeedParser()

try:
Expand Down
3 changes: 1 addition & 2 deletions src/abilian/web/admin/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import TYPE_CHECKING, Any

from flask import Blueprint, Flask, g
from flask.sansio.scaffold import _endpoint_from_view_func
from flask_login import current_user
from loguru import logger
from werkzeug.exceptions import Forbidden
Expand Down Expand Up @@ -153,7 +152,7 @@ def add_url_rule(
raise ValueError(msg)

if endpoint is None:
endpoint = _endpoint_from_view_func(view_func)
endpoint = view_func.__name__

if not endpoint.startswith(base_endpoint):
endpoint = f"{base_endpoint}_{endpoint}"
Expand Down
6 changes: 3 additions & 3 deletions tests/sbe/apps/forum/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from flask_login import login_user

from abilian.sbe.apps.communities.models import MANAGER, MEMBER
from abilian.sbe.apps.forum.cli import _inject_email
from abilian.sbe.apps.forum.cli import do_inject_email
from abilian.sbe.apps.forum.models import Post, Thread
from abilian.sbe.apps.forum.tasks import (
build_reply_email_address,
Expand Down Expand Up @@ -265,7 +265,7 @@ def test_parse_forum_email(mock_process_email, mock_email):
mock_email.return_value = get_string_from_file("notification.email")

# test the parsing function
_inject_email()
do_inject_email()

# assert the email is read
assert mock_email.called
Expand All @@ -279,6 +279,6 @@ def test_parse_forum_email(mock_process_email, mock_email):
assert not mock_process_email.delay.called

mock_email.return_value = get_string_from_file("defects.email")
_inject_email()
do_inject_email()
assert mock_email.called
assert not mock_process_email.delay.called

0 comments on commit 580e79c

Please sign in to comment.