diff --git a/funnel/devtest.py b/funnel/devtest.py index 69a9457fb..b0c6904f3 100644 --- a/funnel/devtest.py +++ b/funnel/devtest.py @@ -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, @@ -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, @@ -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, diff --git a/funnel/models/label.py b/funnel/models/label.py index 7f805f19b..9c87d3f32 100644 --- a/funnel/models/label.py +++ b/funnel/models/label.py @@ -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: diff --git a/funnel/registry.py b/funnel/registry.py index 788024ace..9140d0f48 100644 --- a/funnel/registry.py +++ b/funnel/registry.py @@ -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, diff --git a/funnel/transports/email/send.py b/funnel/transports/email/send.py index 8be57bf26..d38aabd6e 100644 --- a/funnel/transports/email/send.py +++ b/funnel/transports/email/send.py @@ -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, diff --git a/funnel/utils/markdown/base.py b/funnel/utils/markdown/base.py index aa6bc46ed..9ab79b049 100644 --- a/funnel/utils/markdown/base.py +++ b/funnel/utils/markdown/base.py @@ -1,5 +1,4 @@ """Markdown parser and config profiles.""" -# pylint: disable=too-many-arguments from __future__ import annotations diff --git a/funnel/views/helpers.py b/funnel/views/helpers.py index d6e1b5b3e..daa5f203c 100644 --- a/funnel/views/helpers.py +++ b/funnel/views/helpers.py @@ -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, @@ -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, diff --git a/funnel/views/otp.py b/funnel/views/otp.py index 42457831b..9e7264935 100644 --- a/funnel/views/otp.py +++ b/funnel/views/otp.py @@ -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, diff --git a/funnel/views/search.py b/funnel/views/search.py index a610de7e4..0c8feb321 100644 --- a/funnel/views/search.py +++ b/funnel/views/search.py @@ -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, diff --git a/pyproject.toml b/pyproject.toml index 8315f09d9..e49e81362 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py index 6794fa1f7..2f1b4f590 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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, diff --git a/tests/integration/views/comment_moderation_test.py b/tests/integration/views/comment_moderation_test.py index 691890c92..6f04aef37 100644 --- a/tests/integration/views/comment_moderation_test.py +++ b/tests/integration/views/comment_moderation_test.py @@ -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 diff --git a/tests/integration/views/label_views_test.py b/tests/integration/views/label_views_test.py index 04ce37ac8..0f83bf7b3 100644 --- a/tests/integration/views/label_views_test.py +++ b/tests/integration/views/label_views_test.py @@ -1,5 +1,4 @@ """Test Label views.""" -# pylint: disable=too-many-arguments import pytest diff --git a/tests/integration/views/oauth_test.py b/tests/integration/views/oauth_test.py index 2f94e1124..c14759683 100644 --- a/tests/integration/views/oauth_test.py +++ b/tests/integration/views/oauth_test.py @@ -51,7 +51,7 @@ def test_authcode_wellformed( @pytest.mark.dbcommit() @pytest.mark.filterwarnings("ignore:Object of type 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.""" diff --git a/tests/unit/forms/proposal_forms_test.py b/tests/unit/forms/proposal_forms_test.py index 3bb73d6e5..1c9294573 100644 --- a/tests/unit/forms/proposal_forms_test.py +++ b/tests/unit/forms/proposal_forms_test.py @@ -1,5 +1,4 @@ """Tests for Proposal forms.""" -# pylint: disable=too-many-arguments from funnel import models diff --git a/tests/unit/models/merge_membership_test.py b/tests/unit/models/merge_membership_test.py index 011351e27..47d150fe4 100644 --- a/tests/unit/models/merge_membership_test.py +++ b/tests/unit/models/merge_membership_test.py @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/tests/unit/models/merge_notification_test.py b/tests/unit/models/merge_notification_test.py index ebc4cefdd..333f65bd5 100644 --- a/tests/unit/models/merge_notification_test.py +++ b/tests/unit/models/merge_notification_test.py @@ -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, diff --git a/tests/unit/models/sponsor_membership_test.py b/tests/unit/models/sponsor_membership_test.py index 6792bfe9a..217c4c370 100644 --- a/tests/unit/models/sponsor_membership_test.py +++ b/tests/unit/models/sponsor_membership_test.py @@ -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, @@ -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, @@ -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, diff --git a/tests/unit/models/user_User_test.py b/tests/unit/models/user_User_test.py index 8463ccba2..0889bbecc 100644 --- a/tests/unit/models/user_User_test.py +++ b/tests/unit/models/user_User_test.py @@ -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, diff --git a/tests/unit/utils/markdown/conftest.py b/tests/unit/utils/markdown/conftest.py index 974847e54..262c2748c 100644 --- a/tests/unit/utils/markdown/conftest.py +++ b/tests/unit/utils/markdown/conftest.py @@ -1,5 +1,4 @@ """Test configuration for markdown tests.""" -# pylint: disable=too-many-arguments from copy import copy from datetime import datetime diff --git a/tests/unit/utils/markdown/markdown_test.py b/tests/unit/utils/markdown/markdown_test.py index 1e3041a99..e5fca16f1 100644 --- a/tests/unit/utils/markdown/markdown_test.py +++ b/tests/unit/utils/markdown/markdown_test.py @@ -1,5 +1,4 @@ """Tests for markdown parser.""" -# pylint: disable=too-many-arguments import warnings diff --git a/tests/unit/views/account_menu_test.py b/tests/unit/views/account_menu_test.py index 4b340d7ec..4b340cdb7 100644 --- a/tests/unit/views/account_menu_test.py +++ b/tests/unit/views/account_menu_test.py @@ -1,5 +1,4 @@ """Tests for account menu drop-down views.""" -# pylint: disable=too-many-arguments import time diff --git a/tests/unit/views/api_shortlink_test.py b/tests/unit/views/api_shortlink_test.py index 92f53d64a..fb4a9d39c 100644 --- a/tests/unit/views/api_shortlink_test.py +++ b/tests/unit/views/api_shortlink_test.py @@ -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.""" diff --git a/tests/unit/views/login_session_test.py b/tests/unit/views/login_session_test.py index d32bc12b2..900e0b13b 100644 --- a/tests/unit/views/login_session_test.py +++ b/tests/unit/views/login_session_test.py @@ -1,5 +1,4 @@ """Test login session helpers.""" -# pylint: disable=too-many-arguments from flask import session diff --git a/tests/unit/views/notifications/organization_membership_notification_test.py b/tests/unit/views/notifications/organization_membership_notification_test.py index ea4cec561..28675eb0d 100644 --- a/tests/unit/views/notifications/organization_membership_notification_test.py +++ b/tests/unit/views/notifications/organization_membership_notification_test.py @@ -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 diff --git a/tests/unit/views/notifications/project_crew_notification_test.py b/tests/unit/views/notifications/project_crew_notification_test.py index 6813be858..9f512d83c 100644 --- a/tests/unit/views/notifications/project_crew_notification_test.py +++ b/tests/unit/views/notifications/project_crew_notification_test.py @@ -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 diff --git a/tests/unit/views/project_spa_test.py b/tests/unit/views/project_spa_test.py index ab7b606bd..88785acfb 100644 --- a/tests/unit/views/project_spa_test.py +++ b/tests/unit/views/project_spa_test.py @@ -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], @@ -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], @@ -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], diff --git a/tests/unit/views/project_sponsorship_test.py b/tests/unit/views/project_sponsorship_test.py index 619da6dd1..ad87fffb1 100644 --- a/tests/unit/views/project_sponsorship_test.py +++ b/tests/unit/views/project_sponsorship_test.py @@ -1,5 +1,4 @@ """Test ProjectSponsorship views.""" -# pylint: disable=too-many-arguments import pytest @@ -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) @@ -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, @@ -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,