forked from mirrors/bookwyrm
More pylint fixes
This commit is contained in:
parent
381d160105
commit
9e5c7053e9
12 changed files with 21 additions and 9 deletions
2
.github/workflows/pylint.yml
vendored
2
.github/workflows/pylint.yml
vendored
|
@ -20,5 +20,5 @@ jobs:
|
||||||
pip install pylint
|
pip install pylint
|
||||||
- name: Analysing the code with pylint
|
- name: Analysing the code with pylint
|
||||||
run: |
|
run: |
|
||||||
pylint bookwyrm/ --ignore=migrations,__init__ --disable=E1101,E1135,E1136,R0903,R0901,R0902,W0707,W0511,W0406
|
pylint bookwyrm/ --ignore=migrations,tests --disable=E1101,E1135,E1136,R0903,R0901,R0902,W0707,W0511,W0406,R0401
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ class Tombstone(ActivityObject):
|
||||||
return model.find_existing_by_remote_id(self.id)
|
return model.find_existing_by_remote_id(self.id)
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class Note(ActivityObject):
|
class Note(ActivityObject):
|
||||||
"""Note activity"""
|
"""Note activity"""
|
||||||
|
@ -52,6 +53,7 @@ class GeneratedNote(Note):
|
||||||
type: str = "GeneratedNote"
|
type: str = "GeneratedNote"
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class Comment(Note):
|
class Comment(Note):
|
||||||
"""like a note but with a book"""
|
"""like a note but with a book"""
|
||||||
|
|
|
@ -5,6 +5,7 @@ from typing import List
|
||||||
from .base_activity import ActivityObject
|
from .base_activity import ActivityObject
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class OrderedCollection(ActivityObject):
|
class OrderedCollection(ActivityObject):
|
||||||
"""structure of an ordered collection activity"""
|
"""structure of an ordered collection activity"""
|
||||||
|
@ -17,6 +18,7 @@ class OrderedCollection(ActivityObject):
|
||||||
type: str = "OrderedCollection"
|
type: str = "OrderedCollection"
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class OrderedCollectionPrivate(OrderedCollection):
|
class OrderedCollectionPrivate(OrderedCollection):
|
||||||
"""an ordered collection with privacy settings"""
|
"""an ordered collection with privacy settings"""
|
||||||
|
@ -41,6 +43,7 @@ class BookList(OrderedCollectionPrivate):
|
||||||
type: str = "BookList"
|
type: str = "BookList"
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class OrderedCollectionPage(ActivityObject):
|
class OrderedCollectionPage(ActivityObject):
|
||||||
"""structure of an ordered collection activity"""
|
"""structure of an ordered collection activity"""
|
||||||
|
|
|
@ -6,6 +6,7 @@ from .base_activity import ActivityObject
|
||||||
from .image import Image
|
from .image import Image
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class PublicKey(ActivityObject):
|
class PublicKey(ActivityObject):
|
||||||
"""public key block"""
|
"""public key block"""
|
||||||
|
@ -15,6 +16,7 @@ class PublicKey(ActivityObject):
|
||||||
type: str = "PublicKey"
|
type: str = "PublicKey"
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class Person(ActivityObject):
|
class Person(ActivityObject):
|
||||||
"""actor activitypub json"""
|
"""actor activitypub json"""
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
""" ActivityPub-specific json response wrapper """
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
|
|
||||||
from .base_activity import ActivityEncoder
|
from .base_activity import ActivityEncoder
|
||||||
|
|
|
@ -38,17 +38,17 @@ def search(query, min_confidence=0.1, return_first=False):
|
||||||
# Search on ISBN
|
# Search on ISBN
|
||||||
try:
|
try:
|
||||||
result_set = connector.isbn_search(isbn)
|
result_set = connector.isbn_search(isbn)
|
||||||
except Exception as e: # pylint: disable=broad-except
|
except Exception as err: # pylint: disable=broad-except
|
||||||
logger.exception(e)
|
logger.exception(err)
|
||||||
# if this fails, we can still try regular search
|
# if this fails, we can still try regular search
|
||||||
|
|
||||||
# if no isbn search results, we fallback to generic search
|
# if no isbn search results, we fallback to generic search
|
||||||
if not result_set:
|
if not result_set:
|
||||||
try:
|
try:
|
||||||
result_set = connector.search(query, min_confidence=min_confidence)
|
result_set = connector.search(query, min_confidence=min_confidence)
|
||||||
except Exception as e: # pylint: disable=broad-except
|
except Exception as err: # pylint: disable=broad-except
|
||||||
# we don't want *any* error to crash the whole search page
|
# we don't want *any* error to crash the whole search page
|
||||||
logger.exception(e)
|
logger.exception(err)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if return_first and result_set:
|
if return_first and result_set:
|
||||||
|
|
|
@ -114,6 +114,7 @@ class Connector(AbstractConnector):
|
||||||
|
|
||||||
def search_identifiers(query, *filters):
|
def search_identifiers(query, *filters):
|
||||||
"""tries remote_id, isbn; defined as dedupe fields on the model"""
|
"""tries remote_id, isbn; defined as dedupe fields on the model"""
|
||||||
|
# pylint: disable=W0212
|
||||||
or_filters = [
|
or_filters = [
|
||||||
{f.name: query}
|
{f.name: query}
|
||||||
for f in models.Edition._meta.get_fields()
|
for f in models.Edition._meta.get_fields()
|
||||||
|
|
|
@ -67,8 +67,8 @@ def import_data(source, job_id):
|
||||||
for item in job.items.all():
|
for item in job.items.all():
|
||||||
try:
|
try:
|
||||||
item.resolve()
|
item.resolve()
|
||||||
except Exception as e: # pylint: disable=broad-except
|
except Exception as err: # pylint: disable=broad-except
|
||||||
logger.exception(e)
|
logger.exception(err)
|
||||||
item.fail_reason = "Error loading book"
|
item.fail_reason = "Error loading book"
|
||||||
item.save()
|
item.save()
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -202,6 +202,7 @@ class PrivacyField(ActivitypubFieldMixin, models.CharField):
|
||||||
*args, max_length=255, choices=PrivacyLevels.choices, default="public"
|
*args, max_length=255, choices=PrivacyLevels.choices, default="public"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
def set_field_from_activity(self, instance, data):
|
def set_field_from_activity(self, instance, data):
|
||||||
to = data.to
|
to = data.to
|
||||||
cc = data.cc
|
cc = data.cc
|
||||||
|
@ -220,6 +221,7 @@ class PrivacyField(ActivitypubFieldMixin, models.CharField):
|
||||||
if hasattr(instance, "mention_users"):
|
if hasattr(instance, "mention_users"):
|
||||||
mentions = [u.remote_id for u in instance.mention_users.all()]
|
mentions = [u.remote_id for u in instance.mention_users.all()]
|
||||||
# this is a link to the followers list
|
# this is a link to the followers list
|
||||||
|
# pylint: disable=protected-access
|
||||||
followers = instance.user.__class__._meta.get_field(
|
followers = instance.user.__class__._meta.get_field(
|
||||||
"followers"
|
"followers"
|
||||||
).field_to_activity(instance.user.followers)
|
).field_to_activity(instance.user.followers)
|
||||||
|
|
|
@ -99,7 +99,7 @@ class UserFollowRequest(ActivitypubMixin, UserRelationship):
|
||||||
status = "follow_request"
|
status = "follow_request"
|
||||||
activity_serializer = activitypub.Follow
|
activity_serializer = activitypub.Follow
|
||||||
|
|
||||||
def save(self, *args, broadcast=True, **kwargs):
|
def save(self, *args, broadcast=True, **kwargs): # pylint: disable=arguments-differ
|
||||||
"""make sure the follow or block relationship doesn't already exist"""
|
"""make sure the follow or block relationship doesn't already exist"""
|
||||||
# if there's a request for a follow that already exists, accept it
|
# if there's a request for a follow that already exists, accept it
|
||||||
# without changing the local database state
|
# without changing the local database state
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
""" useful regex """
|
||||||
from .regex import USERNAME
|
from .regex import USERNAME
|
||||||
|
|
|
@ -133,7 +133,7 @@ def find_mentions(content):
|
||||||
"""detect @mentions in raw status content"""
|
"""detect @mentions in raw status content"""
|
||||||
if not content:
|
if not content:
|
||||||
return
|
return
|
||||||
for match in re.finditer(rhandle_reading_status, egex.STRICT_USERNAME, content):
|
for match in re.finditer(regex.STRICT_USERNAME, content):
|
||||||
username = match.group().strip().split("@")[1:]
|
username = match.group().strip().split("@")[1:]
|
||||||
if len(username) == 1:
|
if len(username) == 1:
|
||||||
# this looks like a local user (@user), fill in the domain
|
# this looks like a local user (@user), fill in the domain
|
||||||
|
|
Loading…
Reference in a new issue