From d5fe63791ae15ed97a7348332f6bfe3e5d38d30e Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Thu, 30 Aug 2018 02:05:35 -0600 Subject: [PATCH] Clean up unnecessary linting disables These disables no longer seem to be necessary, due to switching to Prospector. Some may be related to newer versions of astroid, pylint, or other reasons. --- tildes/prospector.yaml | 1 - tildes/tests/conftest.py | 3 +-- tildes/tildes/enums.py | 4 ++-- tildes/tildes/lib/markdown.py | 2 +- tildes/tildes/models/comment/comment.py | 1 - tildes/tildes/models/database_model.py | 2 +- tildes/tildes/models/log/log.py | 16 ++++++++-------- tildes/tildes/models/model_query.py | 3 +-- tildes/tildes/models/pagination.py | 2 +- tildes/tildes/views/topic.py | 4 +--- 10 files changed, 16 insertions(+), 22 deletions(-) diff --git a/tildes/prospector.yaml b/tildes/prospector.yaml index d3f075d..545fbc7 100644 --- a/tildes/prospector.yaml +++ b/tildes/prospector.yaml @@ -23,7 +23,6 @@ pyflakes: - F401 # unused imports, triggers in __init__.py and pylint can handle it otherwise pylint: - enable: all disable: - bad-continuation # let Black handle line-wrapping - comparison-with-callable # seems to have a lot of false positives diff --git a/tildes/tests/conftest.py b/tildes/tests/conftest.py index ddc1d9c..8877798 100644 --- a/tildes/tests/conftest.py +++ b/tildes/tests/conftest.py @@ -9,7 +9,7 @@ from sqlalchemy import create_engine from sqlalchemy.engine.url import make_url from sqlalchemy.orm import sessionmaker from sqlalchemy.orm.session import Session -from testing.redis import RedisServer # noqa +from testing.redis import RedisServer from webtest import TestApp from scripts.initialize_db import create_tables @@ -178,7 +178,6 @@ def base_app(overall_redis_session, sdb): testing_app.app.registry._redis_sessions = overall_redis_session def redis_factory(request): - # pylint: disable=unused-argument return overall_redis_session testing_app.app.registry["redis_connection_factory"] = redis_factory diff --git a/tildes/tildes/enums.py b/tildes/tildes/enums.py index bd6b7f9..1492a15 100644 --- a/tildes/tildes/enums.py +++ b/tildes/tildes/enums.py @@ -26,7 +26,7 @@ class CommentSortOption(enum.Enum): elif self.name == "POSTED": return "order posted" - return "most {}".format(self.name.lower()) # noqa + return "most {}".format(self.name.lower()) class CommentTagOption(enum.Enum): @@ -83,7 +83,7 @@ class TopicSortOption(enum.Enum): elif self.name == "ACTIVITY": return "activity" - return "most {}".format(self.name.lower()) # noqa + return "most {}".format(self.name.lower()) class TopicType(enum.Enum): diff --git a/tildes/tildes/lib/markdown.py b/tildes/tildes/lib/markdown.py index 54a5b56..42b878b 100644 --- a/tildes/tildes/lib/markdown.py +++ b/tildes/tildes/lib/markdown.py @@ -91,7 +91,7 @@ BAD_ORDERED_LIST_REGEX = re.compile( # looks pretty ridiculous, but it's a dict where the keys are namespaced attr names, # like `(None, 'href')`, and there's also a `_text` key for getting the innerText of the # tag. -NamespacedAttrDict = Dict[Union[Tuple[Optional[str], str], str], str] # noqa +NamespacedAttrDict = Dict[Union[Tuple[Optional[str], str], str], str] def linkify_protocol_whitelist( diff --git a/tildes/tildes/models/comment/comment.py b/tildes/tildes/models/comment/comment.py index a58f48f..acac119 100644 --- a/tildes/tildes/models/comment/comment.py +++ b/tildes/tildes/models/comment/comment.py @@ -91,7 +91,6 @@ class Comment(DatabaseModel): @hybrid_property def markdown(self) -> str: """Return the comment's markdown.""" - # pylint: disable=method-hidden return self._markdown @markdown.setter # type: ignore diff --git a/tildes/tildes/models/database_model.py b/tildes/tildes/models/database_model.py index 0e166e3..f49e187 100644 --- a/tildes/tildes/models/database_model.py +++ b/tildes/tildes/models/database_model.py @@ -113,7 +113,7 @@ class DatabaseModelBase: return result.data[attribute] -DatabaseModel = declarative_base( # pylint: disable=invalid-name +DatabaseModel = declarative_base( cls=DatabaseModelBase, name="DatabaseModel", metadata=MetaData(naming_convention=NAMING_CONVENTION), diff --git a/tildes/tildes/models/log/log.py b/tildes/tildes/models/log/log.py index 7b92478..a342fea 100644 --- a/tildes/tildes/models/log/log.py +++ b/tildes/tildes/models/log/log.py @@ -114,7 +114,7 @@ class LogComment(DatabaseModel, BaseLog): def __str__(self) -> str: """Return a string representation of the log event.""" - return f"performed action {self.event_type.name}" # noqa + return f"performed action {self.event_type.name}" class LogTopic(DatabaseModel, BaseLog): @@ -146,8 +146,8 @@ class LogTopic(DatabaseModel, BaseLog): if self.event_type == LogEventType.TOPIC_TAG: return self._tag_event_description() elif self.event_type == LogEventType.TOPIC_MOVE: - old_group = self.info["old"] # noqa - new_group = self.info["new"] # noqa + old_group = self.info["old"] + new_group = self.info["new"] return f"moved from ~{old_group} to ~{new_group}" elif self.event_type == LogEventType.TOPIC_LOCK: return "locked comments" @@ -158,19 +158,19 @@ class LogTopic(DatabaseModel, BaseLog): elif self.event_type == LogEventType.TOPIC_UNREMOVE: return "un-removed" elif self.event_type == LogEventType.TOPIC_TITLE_EDIT: - old_title = self.info["old"] # noqa - new_title = self.info["new"] # noqa + old_title = self.info["old"] + new_title = self.info["new"] return f'changed title from "{old_title}" to "{new_title}"' - return f"performed action {self.event_type.name}" # noqa + return f"performed action {self.event_type.name}" def _tag_event_description(self) -> str: """Return a description of a TOPIC_TAG event as a string.""" if self.event_type != LogEventType.TOPIC_TAG: raise TypeError - old_tags = set(self.info["old"]) # noqa - new_tags = set(self.info["new"]) # noqa + old_tags = set(self.info["old"]) + new_tags = set(self.info["new"]) added_tags = new_tags - old_tags removed_tags = old_tags - new_tags diff --git a/tildes/tildes/models/model_query.py b/tildes/tildes/models/model_query.py index 69bd114..3be0c6a 100644 --- a/tildes/tildes/models/model_query.py +++ b/tildes/tildes/models/model_query.py @@ -9,7 +9,7 @@ from sqlalchemy.orm import Load, undefer from sqlalchemy.orm.query import Query -ModelType = TypeVar("ModelType") # pylint: disable=invalid-name +ModelType = TypeVar("ModelType") class ModelQuery(Query): @@ -113,7 +113,6 @@ class ModelQuery(Query): This is useful for being able to load an item "fully" in a single query and avoid needing to make additional queries for related items. """ - # pylint: disable=no-member self = self.options(Load(self.model_cls).joinedload("*")) return self diff --git a/tildes/tildes/models/pagination.py b/tildes/tildes/models/pagination.py index f3f8a90..73cfe14 100644 --- a/tildes/tildes/models/pagination.py +++ b/tildes/tildes/models/pagination.py @@ -9,7 +9,7 @@ from tildes.lib.id import id_to_id36, id36_to_id from .model_query import ModelQuery -ModelType = TypeVar("ModelType") # pylint: disable=invalid-name +ModelType = TypeVar("ModelType") class PaginatedQuery(ModelQuery): diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index b59b180..a7fb983 100644 --- a/tildes/tildes/views/topic.py +++ b/tildes/tildes/views/topic.py @@ -265,9 +265,7 @@ def get_topic(request: Request, comment_order: CommentSortOption) -> dict: ) log = ( request.query(LogTopic) - .filter( - LogTopic.topic == topic, LogTopic.event_type.in_(visible_events) # noqa - ) + .filter(LogTopic.topic == topic, LogTopic.event_type.in_(visible_events)) .order_by(desc(LogTopic.event_time)) .all() )