Skip to content

Commit 4d3809b

Browse files
committed
Lint: run prospector and fix code manually
1 parent cbcd425 commit 4d3809b

File tree

21 files changed

+24
-30
lines changed

21 files changed

+24
-30
lines changed

readthedocs/api/v3/serializers.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class BuildConfigSerializer(FlexFieldsSerializerMixin, serializers.Serializer):
128128
which may produce incompatible changes in the API.
129129
"""
130130

131-
def to_representation(self, instance): # pylint: disable=arguments-differ
131+
def to_representation(self, instance):
132132
# For now, we want to return the ``config`` object as it is without
133133
# manipulating it.
134134
return instance
@@ -504,7 +504,7 @@ def validate_name(self, value):
504504
)
505505
return value
506506

507-
def validate(self, data): # pylint: disable=arguments-differ
507+
def validate(self, data): # pylint: disable=arguments-renamed
508508
repo = data.get("repo")
509509
try:
510510
# We are looking for an exact match of the repository URL entered
@@ -730,8 +730,7 @@ def validate_alias(self, value):
730730
)
731731
return value
732732

733-
# pylint: disable=arguments-differ
734-
def validate(self, data):
733+
def validate(self, data): # pylint: disable=arguments-renamed
735734
self.parent_project.is_valid_as_superproject(serializers.ValidationError)
736735
return data
737736

readthedocs/api/v3/urls.py

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# allows /api/v3/projects/
1919
# allows /api/v3/projects/pip/
2020
# allows /api/v3/projects/pip/superproject/
21-
# pylint: disable=assignment-from-no-return
2221
projects = router.register(
2322
r"projects",
2423
ProjectsViewSet,

readthedocs/audit/serializers.py

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class Meta:
6262
"from_user",
6363
]
6464

65-
# pylint: disable=no-self-use
6665
def get_object(self, obj):
6766
# The type of obj depends on the invitation,
6867
# a different serializer is used for each type.

readthedocs/builds/version_slug.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def __init__(self, *args, **kwargs):
7474
super().__init__(*args, **kwargs)
7575

7676
def get_queryset(self, model_cls, slug_field):
77-
# pylint: disable=protected-access
7877
for field, model in get_fields_with_model(model_cls):
7978
if model and field == slug_field:
8079
return model._default_manager.all()
@@ -154,7 +153,6 @@ def uniquifying_suffix(self, iteration):
154153

155154
def create_slug(self, model_instance):
156155
"""Generate a unique slug for a model instance."""
157-
# pylint: disable=protected-access
158156

159157
# get fields to populate from and slug field to set
160158
slug_field = model_instance._meta.get_field(self.attname)
@@ -197,6 +195,7 @@ def create_slug(self, model_instance):
197195

198196
is_slug_valid = self.test_pattern.match(slug)
199197
if not is_slug_valid:
198+
# pylint: disable=broad-exception-raised
200199
raise Exception("Invalid generated slug: {slug}".format(slug=slug))
201200
return slug
202201

readthedocs/builds/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def _get_versions(self, project):
123123

124124

125125
class BuildList(BuildBase, BuildTriggerMixin, ListView):
126-
def get_context_data(self, **kwargs): # pylint: disable=arguments-differ
126+
def get_context_data(self, **kwargs):
127127
context = super().get_context_data(**kwargs)
128128

129129
active_builds = (

readthedocs/core/logs.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class ReadTheDocsRequestMiddleware(RequestMiddleware):
2323
2424
"""
2525

26-
def format_request(self, request):
26+
@staticmethod
27+
def format_request(request):
2728
return request.build_absolute_uri()
2829

2930

readthedocs/core/utils/extend.py

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def get_override_class(proxy_class, default_class=None):
2424
]
2525
)
2626
class_path = settings.CLASS_OVERRIDES.get(class_id)
27-
# pylint: disable=protected-access
2827
if class_path is None and proxy_class._override_setting is not None:
2928
class_path = getattr(settings, proxy_class._override_setting, None)
3029
if class_path is not None:

readthedocs/embed/v3/views.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def has_permission(self, request, view):
4141

4242
class EmbedAPIBase(EmbedAPIMixin, CDNCacheTagsMixin, APIView):
4343
# pylint: disable=line-too-long
44-
# pylint: disable=no-self-use
4544

4645
"""
4746
Embed a section of content from any Read the Docs page.
@@ -154,7 +153,7 @@ def _find_main_node(self, html):
154153
return first_header.parent
155154

156155
def _parse_based_on_doctool(self, page_content, fragment, doctool, doctoolversion):
157-
# pylint: disable=unused-argument disable=too-many-branches disable=too-many-nested-blocks
156+
# pylint: disable=unused-argument disable=too-many-nested-blocks
158157
if not page_content:
159158
return
160159

readthedocs/gold/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ def __str__(self):
5555

5656
@property
5757
def num_supported_projects(self):
58-
dollars = int(self.level.split("-")[-1])
58+
dollars = int(self.level.rsplit("-", maxsplit=1)[-1])
5959
num_projects = int(math.floor(dollars // DOLLARS_PER_PROJECT))
6060
return num_projects

readthedocs/gold/views.py

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ class GoldProjectRemove(GoldProjectsMixin, GenericView):
107107
http_method_names = ["post"]
108108

109109
def post(self, request, *args, **kwargs):
110-
# pylint: disable=unused-argument
111110
gold_user = self.get_gold_user()
112111

113112
project = get_object_or_404(

readthedocs/integrations/models.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def delete_limit(self, related_object, limit=10):
125125

126126
queryset = self.filter(
127127
content_type=ContentType.objects.get(
128-
app_label=model._meta.app_label, # pylint: disable=protected-access
129-
model=model._meta.model_name, # pylint: disable=protected-access
128+
app_label=model._meta.app_label,
129+
model=model._meta.model_name,
130130
),
131131
object_id=related_object.pk,
132132
)
@@ -377,7 +377,7 @@ class GenericAPIWebhook(Integration):
377377
class Meta:
378378
proxy = True
379379

380-
def save(self, *args, **kwargs): # pylint: disable=arguments-differ
380+
def save(self, *args, **kwargs):
381381
"""Ensure model has token data before saving."""
382382
try:
383383
token = self.provider_data.get("token")

readthedocs/notifications/notification.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_context_data(self):
6464
def get_template_names(self, backend_name, source_format=constants.HTML):
6565
names = []
6666
if self.object and isinstance(self.object, models.Model):
67-
meta = self.object._meta # pylint: disable=protected-access
67+
meta = self.object._meta
6868
names.append(
6969
"{app}/notifications/{name}_{backend}.{source_format}".format(
7070
app=self.app_templates or meta.app_label,
@@ -160,7 +160,7 @@ def get_message(self, success):
160160
msg = "" # default message in case of error
161161
if isinstance(message, dict):
162162
if self.reason:
163-
if self.reason in message:
163+
if self.reason in message.keys():
164164
msg = message.get(self.reason)
165165
else:
166166
# log the error but not crash
@@ -181,5 +181,5 @@ def get_message(self, success):
181181

182182
return Template(msg).render(context=Context(self.get_context_data()))
183183

184-
def render(self, *args, **kwargs): # pylint: disable=arguments-differ
184+
def render(self, *args, **kwargs):
185185
return self.get_message(self.success)

readthedocs/oauth/management/commands/sync_vcs_data.py

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def handle(self, *args, **options):
9999
if skip_revoked_users:
100100
# `revoked-users.json` was created by a script pullig down data from Sentry
101101
# https://gist.github.com/humitos/aba1a004abeb3552fd8ef9a741f5dce1
102+
# pylint: disable=consider-using-with disable=unspecified-encoding
102103
revoked_users = json.load(open("revoked-users.json", "r"))
103104
users = users.exclude(username__in=revoked_users)
104105
self.stdout.write(

readthedocs/projects/management/commands/import_project_from_live.py

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def handle(self, *args, **options):
5353
"https://readthedocs.org/api/v2/project/",
5454
params={"slug": slug},
5555
auth=auth,
56+
timeout=3,
5657
)
5758
resp.raise_for_status() # This should only fail if RTD is having issues
5859
response_data = resp.json()

readthedocs/projects/tag_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def import_tags(project):
7878
"client_secret": provider.secret,
7979
}
8080

81-
resp = requests.get(url, headers=headers, params=params)
81+
resp = requests.get(url, headers=headers, params=params, timeout=3)
8282
if resp.ok:
8383
tags = resp.json()["names"]
8484
if tags:

readthedocs/projects/views/public.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_queryset(self):
6363

6464
return queryset
6565

66-
def get_context_data(self, **kwargs): # pylint: disable=arguments-differ
66+
def get_context_data(self, **kwargs):
6767
context = super().get_context_data(**kwargs)
6868
context["tag"] = self.tag
6969
return context
@@ -232,6 +232,7 @@ def serve_badge(self, request, status):
232232
)
233233

234234
try:
235+
# pylint: disable=unspecified-encoding
235236
with open(badge_path) as fd:
236237
return HttpResponse(
237238
fd.read(),

readthedocs/redirects/models.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"Example: <b>/docs/</b> or <b>/install.html</b>",
4343
)
4444
to_url_helptext = _(
45-
"Absolute or relative URL. Example: " "<b>/tutorial/install.html</b>",
45+
"Absolute or relative URL. Example: <b>/tutorial/install.html</b>",
4646
)
4747
redirect_type_helptext = _("The type of redirect you wish to use.")
4848

@@ -114,7 +114,7 @@ class Meta:
114114
verbose_name_plural = _("redirects")
115115
ordering = ("-update_dt",)
116116

117-
def save(self, *args, **kwargs): # pylint: disable=arguments-differ
117+
def save(self, *args, **kwargs):
118118
if self.redirect_type == "exact" and "$rest" in self.from_url:
119119
self.from_url_without_rest = self.from_url.replace("$rest", "")
120120
super().save(*args, **kwargs)
@@ -209,7 +209,7 @@ def redirect_exact(self, path, full_path, language=None, version_slug=None):
209209
return self.to_url
210210
# Handle full sub-level redirects
211211
if "$rest" in self.from_url:
212-
match = self.from_url.split("$rest")[0]
212+
match = self.from_url.split("$rest", maxsplit=1)[0]
213213
if full_path.startswith(match):
214214
cut_path = full_path.replace(match, self.to_url, 1)
215215
return cut_path

readthedocs/search/signals.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
log = structlog.get_logger(__name__)
1212

1313

14-
# pylint: disable=unused-argument
1514
@receiver(post_save, sender=Project)
1615
def index_project_save(instance, *args, **kwargs):
1716
"""

readthedocs/storage/s3_storage.py

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def _rclone(self):
4141
)
4242

4343

44-
# pylint: disable=too-many-ancestors
4544
class S3BuildMediaStorage(OverrideHostnameMixin, S3BuildMediaStorageMixin):
4645

4746
"""An AWS S3 Storage backend for build artifacts."""

readthedocs/subscriptions/apps.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def ready(self):
1717

1818
self._add_custom_manager()
1919

20-
# pylint: disable=no-self-use
2120
def _add_custom_manager(self):
2221
"""
2322
Add a custom manager to the djstripe Subscription model.

readthedocs/worker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ def register_renamed_tasks(application, renamed_tasks):
7171
return application
7272

7373

74-
app = create_application() # pylint: disable=invalid-name
74+
app = create_application()

0 commit comments

Comments
 (0)