Skip to content

Commit

Permalink
Disable Pylint's too-many-arguments check (#1667)
Browse files Browse the repository at this point in the history
Also relocate disable tags for a couple other checks.
  • Loading branch information
jace authored Mar 14, 2023
1 parent 7ef024c commit 227f194
Show file tree
Hide file tree
Showing 27 changed files with 35 additions and 46 deletions.
6 changes: 3 additions & 3 deletions funnel/devtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def install_mock(func: Callable, mock: Callable) -> None:
ref[key] = mock


def _prepare_subprocess( # pylint: disable=too-many-arguments
def _prepare_subprocess(
engines: Iterable[Engine],
mock_transports: bool,
calls: CapturedCalls,
Expand All @@ -197,7 +197,7 @@ def _prepare_subprocess( # pylint: disable=too-many-arguments

if mock_transports:

def mock_email( # pylint: disable=too-many-arguments
def mock_email(
subject: str,
to: List[Any],
content: str,
Expand Down Expand Up @@ -246,7 +246,7 @@ class BackgroundWorker:
:param mock_transports: Patch transports with mock functions that write to a log
"""

def __init__( # pylint: disable=too-many-arguments
def __init__(
self,
worker: Callable,
args: Optional[Iterable] = None,
Expand Down
5 changes: 2 additions & 3 deletions funnel/models/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ def has_proposals(self) -> bool:

@hybrid_property
def restricted(self) -> bool:
return ( # pylint: disable=protected-access
self.main_label._restricted if self.main_label else self._restricted
)
# pylint: disable=protected-access
return self.main_label._restricted if self.main_label else self._restricted

@restricted.setter
def restricted(self, value: bool) -> None:
Expand Down
2 changes: 1 addition & 1 deletion funnel/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class LoginProvider:
#: used for addressing with @username
at_username = False

def __init__( # pylint: disable=too-many-arguments
def __init__(
self,
name: str,
title: str,
Expand Down
2 changes: 1 addition & 1 deletion funnel/transports/email/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def process_recipient(recipient: EmailRecipient) -> str:
return formataddr((realname, emailaddr))


def send_email( # pylint: disable=too-many-arguments
def send_email(
subject: str,
to: List[EmailRecipient],
content: str,
Expand Down
1 change: 0 additions & 1 deletion funnel/utils/markdown/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Markdown parser and config profiles."""
# pylint: disable=too-many-arguments

from __future__ import annotations

Expand Down
7 changes: 3 additions & 4 deletions funnel/views/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ def app_url_for(
The provided app must have `SERVER_NAME` in its config for URL construction to work.
"""
if ( # pylint: disable=protected-access
current_app and current_app._get_current_object() is target_app
):
# pylint: disable=protected-access
if current_app and current_app._get_current_object() is target_app:
return url_for(
endpoint,
_external=_external,
Expand Down Expand Up @@ -295,7 +294,7 @@ def progressive_rate_limit_validator(
return (True, False)


def validate_rate_limit( # pylint: disable=too-many-arguments
def validate_rate_limit(
resource: str,
identifier: str,
attempts: int,
Expand Down
2 changes: 1 addition & 1 deletion funnel/views/otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init_subclass__(cls, *args, **kwargs) -> None:
cls.reason = reason

@classmethod
def make( # pylint: disable=too-many-arguments
def make(
cls: Type[OtpSessionType],
reason: str,
user: OptionalUserType,
Expand Down
2 changes: 1 addition & 1 deletion funnel/views/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ def search_counts(


# @cache.memoize(timeout=300)
def search_results( # pylint: disable=too-many-arguments
def search_results(
tsquery: sa.sql.functions.Function,
stype: str,
page=1,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ disable = [
'no-member', # Pylint gets confused over how some members become part of an instance
'too-few-public-methods', # Data classes and validator classes have few methods
'too-many-ancestors', # Our models have a large number of mixin classes
'too-many-arguments', # Callables can have many optional arguments
'too-many-instance-attributes', # Some instances are just bags of attributes
'too-many-lines', # We have large files that include all related functionality
'too-many-public-methods', # Models and views have many public methods
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ def client_hex_credential(models, db_session, client_hex) -> SimpleNamespace:


@pytest.fixture()
def all_fixtures( # pylint: disable=too-many-arguments,too-many-locals
def all_fixtures( # pylint: disable=too-many-locals
db_session,
user_twoflower,
user_rincewind,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/views/comment_moderation_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Test comment moderation views."""
# pylint: disable=too-many-arguments,too-many-locals
# pylint: disable=too-many-locals

from flask import url_for
from werkzeug.datastructures import MultiDict
Expand Down
1 change: 0 additions & 1 deletion tests/integration/views/label_views_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test Label views."""
# pylint: disable=too-many-arguments

import pytest

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/views/oauth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_authcode_wellformed(

@pytest.mark.dbcommit()
@pytest.mark.filterwarnings("ignore:Object of type <AuthToken> not in session")
def test_auth_untrusted_confidential( # pylint: disable=too-many-arguments
def test_auth_untrusted_confidential(
client, login, user_rincewind, client_hex, client_hex_credential, csrf_token
) -> None:
"""Test auth on an untrusted confidential auth client."""
Expand Down
1 change: 0 additions & 1 deletion tests/unit/forms/proposal_forms_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tests for Proposal forms."""
# pylint: disable=too-many-arguments

from funnel import models

Expand Down
14 changes: 7 additions & 7 deletions tests/unit/models/merge_membership_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_merge_without_membership(
assert set(org_ankhmorpork.admin_users) == {user_vetinari}


def test_merge_with_death_membership( # pylint: disable=too-many-arguments
def test_merge_with_death_membership(
db_session,
org_ankhmorpork,
user_death,
Expand All @@ -83,7 +83,7 @@ def test_merge_with_death_membership( # pylint: disable=too-many-arguments
assert death_membership.revoked_at is None


def test_merge_with_rincewind_membership( # pylint: disable=too-many-arguments
def test_merge_with_rincewind_membership(
db_session,
org_ankhmorpork,
user_death,
Expand All @@ -104,7 +104,7 @@ def test_merge_with_rincewind_membership( # pylint: disable=too-many-arguments
assert rincewind_membership.revoked_at is None


def test_merge_with_admin_membership( # pylint: disable=too-many-arguments
def test_merge_with_admin_membership(
db_session,
org_ankhmorpork,
user_death,
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_merge_with_admin_membership( # pylint: disable=too-many-arguments
assert rincewind_membership.revoked_at is not None


def test_merge_with_death_owner_membership( # pylint: disable=too-many-arguments
def test_merge_with_death_owner_membership(
db_session,
org_ankhmorpork,
user_death,
Expand Down Expand Up @@ -160,7 +160,7 @@ def test_merge_with_death_owner_membership( # pylint: disable=too-many-argument
assert rincewind_membership.revoked_at is not None


def test_merge_with_rincewind_owner_membership( # pylint: disable=too-many-arguments
def test_merge_with_rincewind_owner_membership(
db_session,
org_ankhmorpork,
user_death,
Expand Down Expand Up @@ -188,7 +188,7 @@ def test_merge_with_rincewind_owner_membership( # pylint: disable=too-many-argu
assert rincewind_owner_membership.revoked_at is not None


def test_merge_with_owner_membership( # pylint: disable=too-many-arguments
def test_merge_with_owner_membership(
db_session,
org_ankhmorpork,
user_death,
Expand Down Expand Up @@ -220,7 +220,7 @@ def test_merge_with_owner_membership( # pylint: disable=too-many-arguments
assert rincewind_owner_membership.revoked_at is not None


def test_merge_multiple_memberships( # pylint: disable=too-many-arguments
def test_merge_multiple_memberships(
db_session,
org_ankhmorpork,
org_uu,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/models/merge_notification_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_merge_with_user2_preferences(
assert user2_test_preferences.user == fixtures.user1


def test_merge_with_both_preferences( # pylint: disable=too-many-arguments
def test_merge_with_both_preferences(
db_session,
fixtures,
user1_main_preferences,
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/models/sponsor_membership_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def dibbler_sponsor(db_session, project_expo2010, user_dibbler, user_vetinari):
return sponsor


def test_auto_seq( # pylint: disable=too-many-arguments
def test_auto_seq(
db_session,
project_expo2010,
org_citywatch,
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_auto_seq( # pylint: disable=too-many-arguments
assert sponsor3.seq == 3


def test_expo_has_sponsors( # pylint: disable=too-many-arguments
def test_expo_has_sponsors(
db_session,
project_expo2010,
dibbler_sponsor,
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_expo_sponsor_reorder(
assert dibbler_sponsor.seq == 1


def test_expo_sponsor_seq_reissue( # pylint: disable=too-many-arguments
def test_expo_sponsor_seq_reissue(
db_session,
project_expo2010,
citywatch_sponsor,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/models/user_User_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_user_autocomplete(


@pytest.mark.parametrize('defercols', [False, True])
def test_user_all( # pylint: disable=too-many-arguments
def test_user_all(
db_session,
user_twoflower,
user_rincewind,
Expand Down
1 change: 0 additions & 1 deletion tests/unit/utils/markdown/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test configuration for markdown tests."""
# pylint: disable=too-many-arguments

from copy import copy
from datetime import datetime
Expand Down
1 change: 0 additions & 1 deletion tests/unit/utils/markdown/markdown_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tests for markdown parser."""
# pylint: disable=too-many-arguments

import warnings

Expand Down
1 change: 0 additions & 1 deletion tests/unit/views/account_menu_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tests for account menu drop-down views."""
# pylint: disable=too-many-arguments

import time

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/views/api_shortlink_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_create_shortlink_name_unauthorized(

@pytest.mark.filterwarnings("ignore:New instance.*conflicts with persistent instance")
@pytest.mark.usefixtures('user_rincewind_site_editor')
def test_create_shortlink_name_authorized( # pylint: disable=too-many-arguments
def test_create_shortlink_name_authorized(
shortlinkapp, client, login, user_rincewind, user_wolfgang, create_shortlink
) -> None:
"""Asking for a custom name will work for site editors."""
Expand Down
1 change: 0 additions & 1 deletion tests/unit/views/login_session_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test login session helpers."""
# pylint: disable=too-many-arguments

from flask import session

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test template strings in project crew membership notifications."""
# pylint: disable=too-many-arguments

from pytest_bdd import given, parsers, scenarios, then, when

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test template strings in project crew membership notifications."""
# pylint: disable=too-many-arguments

from pytest_bdd import given, parsers, scenarios, then, when

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/views/project_spa_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_project_url_is_as_expected(project_url) -> None:
@pytest.mark.parametrize('page', subpages)
@pytest.mark.parametrize('xhr', xhr_headers)
@pytest.mark.parametrize('use_login', login_sessions)
def test_default_is_html( # pylint: disable=too-many-arguments
def test_default_is_html(
request,
client,
use_login: Optional[str],
Expand All @@ -63,7 +63,7 @@ def test_default_is_html( # pylint: disable=too-many-arguments
@pytest.mark.parametrize('page', subpages)
@pytest.mark.parametrize('xhr', xhr_headers)
@pytest.mark.parametrize('use_login', login_sessions)
def test_html_response( # pylint: disable=too-many-arguments
def test_html_response(
request,
client,
use_login: Optional[str],
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_json_response(
@pytest.mark.parametrize('page', subpages)
@pytest.mark.parametrize('xhr', xhr_headers)
@pytest.mark.parametrize('use_login', login_sessions)
def test_htmljson_response( # pylint: disable=too-many-arguments
def test_htmljson_response(
request,
client,
use_login: Optional[str],
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/views/project_sponsorship_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test ProjectSponsorship views."""
# pylint: disable=too-many-arguments

import pytest

Expand Down Expand Up @@ -44,7 +43,7 @@ def user_twoflower_not_site_editor(db_session, user_twoflower):
('user_site_membership', 'status_code'),
[('user_vetinari_site_editor', 200), ('user_twoflower_not_site_editor', 403)],
)
def test_check_site_editor_edit_sponsorship( # pylint: disable=too-many-arguments
def test_check_site_editor_edit_sponsorship(
request, app, client, login, org_uu_sponsorship, user_site_membership, status_code
) -> None:
login.as_(request.getfixturevalue(user_site_membership).user)
Expand All @@ -62,7 +61,7 @@ def test_check_site_editor_edit_sponsorship( # pylint: disable=too-many-argumen
('Test sponsor2', True),
],
)
def test_sponsorship_add( # pylint: disable=too-many-arguments
def test_sponsorship_add(
app,
client,
login,
Expand Down Expand Up @@ -126,7 +125,7 @@ def test_sponsorship_edit(
assert edited_sponsorship.is_promoted is False


def test_sponsorship_remove( # pylint: disable=too-many-arguments
def test_sponsorship_remove(
db_session,
app,
client,
Expand Down

0 comments on commit 227f194

Please sign in to comment.