Browse Source

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.
merge-requests/34/head
Chad Birch 6 years ago
parent
commit
d5fe63791a
  1. 1
      tildes/prospector.yaml
  2. 3
      tildes/tests/conftest.py
  3. 4
      tildes/tildes/enums.py
  4. 2
      tildes/tildes/lib/markdown.py
  5. 1
      tildes/tildes/models/comment/comment.py
  6. 2
      tildes/tildes/models/database_model.py
  7. 16
      tildes/tildes/models/log/log.py
  8. 3
      tildes/tildes/models/model_query.py
  9. 2
      tildes/tildes/models/pagination.py
  10. 4
      tildes/tildes/views/topic.py

1
tildes/prospector.yaml

@ -23,7 +23,6 @@ pyflakes:
- F401 # unused imports, triggers in __init__.py and pylint can handle it otherwise - F401 # unused imports, triggers in __init__.py and pylint can handle it otherwise
pylint: pylint:
enable: all
disable: disable:
- bad-continuation # let Black handle line-wrapping - bad-continuation # let Black handle line-wrapping
- comparison-with-callable # seems to have a lot of false positives - comparison-with-callable # seems to have a lot of false positives

3
tildes/tests/conftest.py

@ -9,7 +9,7 @@ from sqlalchemy import create_engine
from sqlalchemy.engine.url import make_url from sqlalchemy.engine.url import make_url
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm.session import Session from sqlalchemy.orm.session import Session
from testing.redis import RedisServer # noqa
from testing.redis import RedisServer
from webtest import TestApp from webtest import TestApp
from scripts.initialize_db import create_tables 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 testing_app.app.registry._redis_sessions = overall_redis_session
def redis_factory(request): def redis_factory(request):
# pylint: disable=unused-argument
return overall_redis_session return overall_redis_session
testing_app.app.registry["redis_connection_factory"] = redis_factory testing_app.app.registry["redis_connection_factory"] = redis_factory

4
tildes/tildes/enums.py

@ -26,7 +26,7 @@ class CommentSortOption(enum.Enum):
elif self.name == "POSTED": elif self.name == "POSTED":
return "order posted" return "order posted"
return "most {}".format(self.name.lower()) # noqa
return "most {}".format(self.name.lower())
class CommentTagOption(enum.Enum): class CommentTagOption(enum.Enum):
@ -83,7 +83,7 @@ class TopicSortOption(enum.Enum):
elif self.name == "ACTIVITY": elif self.name == "ACTIVITY":
return "activity" return "activity"
return "most {}".format(self.name.lower()) # noqa
return "most {}".format(self.name.lower())
class TopicType(enum.Enum): class TopicType(enum.Enum):

2
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, # 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 # like `(None, 'href')`, and there's also a `_text` key for getting the innerText of the
# <a> tag. # <a> tag.
NamespacedAttrDict = Dict[Union[Tuple[Optional[str], str], str], str] # noqa
NamespacedAttrDict = Dict[Union[Tuple[Optional[str], str], str], str]
def linkify_protocol_whitelist( def linkify_protocol_whitelist(

1
tildes/tildes/models/comment/comment.py

@ -91,7 +91,6 @@ class Comment(DatabaseModel):
@hybrid_property @hybrid_property
def markdown(self) -> str: def markdown(self) -> str:
"""Return the comment's markdown.""" """Return the comment's markdown."""
# pylint: disable=method-hidden
return self._markdown return self._markdown
@markdown.setter # type: ignore @markdown.setter # type: ignore

2
tildes/tildes/models/database_model.py

@ -113,7 +113,7 @@ class DatabaseModelBase:
return result.data[attribute] return result.data[attribute]
DatabaseModel = declarative_base( # pylint: disable=invalid-name
DatabaseModel = declarative_base(
cls=DatabaseModelBase, cls=DatabaseModelBase,
name="DatabaseModel", name="DatabaseModel",
metadata=MetaData(naming_convention=NAMING_CONVENTION), metadata=MetaData(naming_convention=NAMING_CONVENTION),

16
tildes/tildes/models/log/log.py

@ -114,7 +114,7 @@ class LogComment(DatabaseModel, BaseLog):
def __str__(self) -> str: def __str__(self) -> str:
"""Return a string representation of the log event.""" """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): class LogTopic(DatabaseModel, BaseLog):
@ -146,8 +146,8 @@ class LogTopic(DatabaseModel, BaseLog):
if self.event_type == LogEventType.TOPIC_TAG: if self.event_type == LogEventType.TOPIC_TAG:
return self._tag_event_description() return self._tag_event_description()
elif self.event_type == LogEventType.TOPIC_MOVE: 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}" return f"moved from ~{old_group} to ~{new_group}"
elif self.event_type == LogEventType.TOPIC_LOCK: elif self.event_type == LogEventType.TOPIC_LOCK:
return "locked comments" return "locked comments"
@ -158,19 +158,19 @@ class LogTopic(DatabaseModel, BaseLog):
elif self.event_type == LogEventType.TOPIC_UNREMOVE: elif self.event_type == LogEventType.TOPIC_UNREMOVE:
return "un-removed" return "un-removed"
elif self.event_type == LogEventType.TOPIC_TITLE_EDIT: 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'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: def _tag_event_description(self) -> str:
"""Return a description of a TOPIC_TAG event as a string.""" """Return a description of a TOPIC_TAG event as a string."""
if self.event_type != LogEventType.TOPIC_TAG: if self.event_type != LogEventType.TOPIC_TAG:
raise TypeError 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 added_tags = new_tags - old_tags
removed_tags = old_tags - new_tags removed_tags = old_tags - new_tags

3
tildes/tildes/models/model_query.py

@ -9,7 +9,7 @@ from sqlalchemy.orm import Load, undefer
from sqlalchemy.orm.query import Query from sqlalchemy.orm.query import Query
ModelType = TypeVar("ModelType") # pylint: disable=invalid-name
ModelType = TypeVar("ModelType")
class ModelQuery(Query): 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 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. avoid needing to make additional queries for related items.
""" """
# pylint: disable=no-member
self = self.options(Load(self.model_cls).joinedload("*")) self = self.options(Load(self.model_cls).joinedload("*"))
return self return self

2
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 from .model_query import ModelQuery
ModelType = TypeVar("ModelType") # pylint: disable=invalid-name
ModelType = TypeVar("ModelType")
class PaginatedQuery(ModelQuery): class PaginatedQuery(ModelQuery):

4
tildes/tildes/views/topic.py

@ -265,9 +265,7 @@ def get_topic(request: Request, comment_order: CommentSortOption) -> dict:
) )
log = ( log = (
request.query(LogTopic) 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)) .order_by(desc(LogTopic.event_time))
.all() .all()
) )

Loading…
Cancel
Save