Browse Source

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.
merge-requests/85/head
Deimos 5 years ago
parent
commit
f147b5eff0
  1. 6
      tildes/prospector.yaml
  2. 2
      tildes/tildes/lib/database.py
  3. 2
      tildes/tildes/lib/ratelimit.py
  4. 1
      tildes/tildes/models/comment/comment.py
  5. 1
      tildes/tildes/models/comment/comment_label.py
  6. 1
      tildes/tildes/models/log/log.py
  7. 4
      tildes/tildes/models/topic/topic.py
  8. 1
      tildes/tildes/models/topic/topic_schedule.py
  9. 1
      tildes/tildes/scrapers/embedly_scraper.py
  10. 2
      tildes/tildes/views/api/web/exceptions.py
  11. 1
      tildes/tildes/views/api/web/topic.py
  12. 3
      tildes/tildes/views/topic.py
  13. 2
      tildes/tildes/views/user.py

6
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

2
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:

2
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")

1
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

1
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

1
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

4
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

1
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

1
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.")

2
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):

1
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

3
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

2
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)

Loading…
Cancel
Save