From f147b5eff088c32427429234081ad2ef5d685e03 Mon Sep 17 00:00:00 2001 From: Deimos Date: Fri, 4 Oct 2019 18:48:27 -0600 Subject: [PATCH] Globally disable most pylint "too many" checks These checks are more annoying than useful. They almost always just cause me to disable the check instead of change how I'm coding. --- tildes/prospector.yaml | 6 ++++++ tildes/tildes/lib/database.py | 2 +- tildes/tildes/lib/ratelimit.py | 2 -- tildes/tildes/models/comment/comment.py | 1 - tildes/tildes/models/comment/comment_label.py | 1 - tildes/tildes/models/log/log.py | 1 - tildes/tildes/models/topic/topic.py | 4 ---- tildes/tildes/models/topic/topic_schedule.py | 1 - tildes/tildes/scrapers/embedly_scraper.py | 1 - tildes/tildes/views/api/web/exceptions.py | 2 -- tildes/tildes/views/api/web/topic.py | 1 - tildes/tildes/views/topic.py | 3 --- tildes/tildes/views/user.py | 2 -- 13 files changed, 7 insertions(+), 20 deletions(-) diff --git a/tildes/prospector.yaml b/tildes/prospector.yaml index ec5c884..848c712 100644 --- a/tildes/prospector.yaml +++ b/tildes/prospector.yaml @@ -32,6 +32,12 @@ pylint: - no-else-return # elif after return - could refactor to enable this check - no-self-use # schemas do this a lot, would be nice to only disable for schemas - too-few-public-methods # plenty of classes that don't need multiple methods + - too-many-ancestors # almost never helpful + - too-many-arguments # almost never helpful + - too-many-branches # almost never helpful - too-many-instance-attributes # models have many instance attributes + - too-many-locals # almost never helpful + - too-many-public-methods # almost never helpful + - too-many-return-statements # almost never helpful - ungrouped-imports # let isort handle this - unnecessary-pass # I prefer using pass, even when it's not technically necessary diff --git a/tildes/tildes/lib/database.py b/tildes/tildes/lib/database.py index 9e8fc26..91efef4 100644 --- a/tildes/tildes/lib/database.py +++ b/tildes/tildes/lib/database.py @@ -87,7 +87,7 @@ class CIText(UserDefinedType): return process -class ArrayOfLtree(ARRAY): # pylint: disable=too-many-ancestors +class ArrayOfLtree(ARRAY): """Workaround class to support ltree[] columns which don't work "normally". This is heavily based on the ArrayOfEnum class from the SQLAlchemy docs: diff --git a/tildes/tildes/lib/ratelimit.py b/tildes/tildes/lib/ratelimit.py index f5572f6..1c1c4d6 100644 --- a/tildes/tildes/lib/ratelimit.py +++ b/tildes/tildes/lib/ratelimit.py @@ -35,7 +35,6 @@ class RateLimitResult: time_until_retry: Optional[timedelta] = None, ): """Initialize a RateLimitResult.""" - # pylint: disable=too-many-arguments if is_allowed and time_until_retry is not None: raise ValueError("time_until_retry must be None if is_allowed is True") @@ -182,7 +181,6 @@ class RateLimitedAction: up to the same value as `limit` (the full limit may be used at any rate, but never more than `limit` inside any given period). """ - # pylint: disable=too-many-arguments if max_burst and not 1 <= max_burst <= limit: raise ValueError("max_burst must be at least 1 and <= limit") diff --git a/tildes/tildes/models/comment/comment.py b/tildes/tildes/models/comment/comment.py index 97226f9..d305fa4 100644 --- a/tildes/tildes/models/comment/comment.py +++ b/tildes/tildes/models/comment/comment.py @@ -143,7 +143,6 @@ class Comment(DatabaseModel): def __acl__(self) -> Sequence[Tuple[str, Any, str]]: """Pyramid security ACL.""" - # pylint: disable=too-many-branches acl = [] # nobody has any permissions on deleted comments diff --git a/tildes/tildes/models/comment/comment_label.py b/tildes/tildes/models/comment/comment_label.py index 1314c91..35697df 100644 --- a/tildes/tildes/models/comment/comment_label.py +++ b/tildes/tildes/models/comment/comment_label.py @@ -58,7 +58,6 @@ class CommentLabel(DatabaseModel): reason: Optional[str] = None, ): """Add a new label to a comment.""" - # pylint: disable=too-many-arguments self.comment_id = comment.comment_id self.user_id = user.user_id self.label = label diff --git a/tildes/tildes/models/log/log.py b/tildes/tildes/models/log/log.py index b5e7a44..2a1d5bf 100644 --- a/tildes/tildes/models/log/log.py +++ b/tildes/tildes/models/log/log.py @@ -2,7 +2,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later """Contains the Log class.""" -# pylint: disable=too-many-branches,too-many-return-statements from typing import Any, Dict, Optional diff --git a/tildes/tildes/models/topic/topic.py b/tildes/tildes/models/topic/topic.py index e3c5198..25893f3 100644 --- a/tildes/tildes/models/topic/topic.py +++ b/tildes/tildes/models/topic/topic.py @@ -68,8 +68,6 @@ class Topic(DatabaseModel): - deleted_time will be set when is_deleted is set to true """ - # pylint: disable=too-many-public-methods - schema_class = TopicSchema __tablename__ = "topics" @@ -239,7 +237,6 @@ class Topic(DatabaseModel): def __acl__(self) -> Sequence[Tuple[str, Any, str]]: """Pyramid security ACL.""" - # pylint: disable=too-many-branches acl = [] # deleted topics allow "general" viewing, but nothing else @@ -429,7 +426,6 @@ class Topic(DatabaseModel): @property def content_metadata_for_display(self) -> str: """Return a string of the content's metadata, suitable for display.""" - # pylint: disable=too-many-branches metadata_strings = [] # display word count (if we have it) with either type of topic diff --git a/tildes/tildes/models/topic/topic_schedule.py b/tildes/tildes/models/topic/topic_schedule.py index 2e3c6c7..474d1b9 100644 --- a/tildes/tildes/models/topic/topic_schedule.py +++ b/tildes/tildes/models/topic/topic_schedule.py @@ -60,7 +60,6 @@ class TopicSchedule(DatabaseModel): user: Optional[User] = None, ) -> None: """Create a new scheduled topic.""" - # pylint: disable=too-many-arguments self.group = group self.title = title self.markdown = markdown diff --git a/tildes/tildes/scrapers/embedly_scraper.py b/tildes/tildes/scrapers/embedly_scraper.py index 3213ad0..de97de2 100644 --- a/tildes/tildes/scrapers/embedly_scraper.py +++ b/tildes/tildes/scrapers/embedly_scraper.py @@ -47,7 +47,6 @@ class EmbedlyScraper: @staticmethod def get_metadata_from_result(result: ScraperResult) -> Dict[str, Any]: """Get the metadata that we're interested in out of a scrape result.""" - # pylint: disable=too-many-branches if result.scraper_type != ScraperType.EMBEDLY: raise ValueError("Can't process a result from a different scraper.") diff --git a/tildes/tildes/views/api/web/exceptions.py b/tildes/tildes/views/api/web/exceptions.py index 0b4ea96..5ea78bf 100644 --- a/tildes/tildes/views/api/web/exceptions.py +++ b/tildes/tildes/views/api/web/exceptions.py @@ -33,7 +33,6 @@ def _422_response_with_errors(errors: Sequence[str]) -> Response: @ic_view_config(context=ValidationError) def unprocessable_entity(request: Request) -> Response: """Exception view for 422 errors.""" - # pylint: disable=too-many-branches if isinstance(request.exception, ValidationError): validation_error = request.exception else: @@ -64,7 +63,6 @@ def valueerror(request: Request) -> Response: @ic_view_config(context=HTTPNotFound) def error_to_text_response(request: Request) -> Response: """Convert HTML error to a text response for Intercooler to display.""" - # pylint: disable=too-many-branches response = request.exception if isinstance(request.exception, HTTPNotFound): diff --git a/tildes/tildes/views/api/web/topic.py b/tildes/tildes/views/api/web/topic.py index 07dc0b2..6708ea6 100644 --- a/tildes/tildes/views/api/web/topic.py +++ b/tildes/tildes/views/api/web/topic.py @@ -164,7 +164,6 @@ def get_topic_tags(request: Request) -> dict: @use_kwargs({"tags": String(), "conflict_check": String()}) def put_tag_topic(request: Request, tags: str, conflict_check: str) -> dict: """Apply tags to a topic with Intercooler.""" - # pylint: disable=too-many-branches topic = request.context # check for edit conflict by verifying tags didn't change after they loaded the form diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index d7eaa2c..af879b9 100644 --- a/tildes/tildes/views/topic.py +++ b/tildes/tildes/views/topic.py @@ -56,7 +56,6 @@ def post_group_topics( confirm_repost: bool, ) -> Union[HTTPFound, Response]: """Post a new topic to a group.""" - # pylint: disable=too-many-arguments group = request.context if link: @@ -150,7 +149,6 @@ def get_group_topics( unfiltered: bool, ) -> dict: """Get a listing of topics in the group.""" - # pylint: disable=too-many-arguments, too-many-branches, too-many-locals is_home_page = request.matched_route.name == "home" if is_home_page: @@ -278,7 +276,6 @@ def get_search( search: str, ) -> dict: """Get a list of search results.""" - # pylint: disable=too-many-arguments group = None if isinstance(request.context, Group): group = request.context diff --git a/tildes/tildes/views/user.py b/tildes/tildes/views/user.py index 56a368b..91a4bc0 100644 --- a/tildes/tildes/views/user.py +++ b/tildes/tildes/views/user.py @@ -37,7 +37,6 @@ def get_user( order_name: str, post_type: Optional[str] = None, ) -> dict: - # pylint: disable=too-many-arguments """Generate the main user history page.""" user = request.context @@ -115,7 +114,6 @@ def _get_user_posts( per_page: int, ) -> Union[PaginatedResults, MixedPaginatedResults]: """Get the posts to display on a user page (topics, comments, or both).""" - # pylint: disable=too-many-arguments result_sets = [] for type_to_query in types_to_query: query = request.query(type_to_query).filter(type_to_query.user == user)