Skip to content

Commit 91a64cb

Browse files
committed
2 parents b717450 + df52689 commit 91a64cb

File tree

12 files changed

+68
-41
lines changed

12 files changed

+68
-41
lines changed

prospector-more.yml

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ ignore-paths:
1313
- donate/
1414
- gold/
1515
- notifications/
16-
- oauth/
1716
- payments/
1817
- privacy/
1918
- profiles/
@@ -23,7 +22,6 @@ ignore-paths:
2322
- rtd_tests/
2423
- search/
2524
- settings/
26-
- vcs_support/
2725

2826
pylint:
2927
options:

readthedocs/oauth/admin.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
"""Admin configuration for the OAuth app."""
2+
13
from django.contrib import admin
24

35
from .models import RemoteRepository, RemoteOrganization
46

57

68
class RemoteRepositoryAdmin(admin.ModelAdmin):
9+
10+
"""Admin configuration for the RemoteRepository model."""
11+
712
raw_id_fields = ('users',)
813

914

1015
class RemoteOrganizationAdmin(admin.ModelAdmin):
16+
17+
"""Admin configuration for the RemoteOrganization model."""
18+
1119
raw_id_fields = ('users',)
1220

1321

readthedocs/oauth/services/bitbucket.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def create_repository(self, fields, privacy=DEFAULT_PRIVACY_LEVEL,
107107
account=self.account,
108108
)
109109
if repo.organization and repo.organization != organization:
110-
log.debug('Not importing %s because mismatched orgs' %
110+
log.debug('Not importing %s because mismatched orgs',
111111
fields['name'])
112112
return None
113113
else:
@@ -139,7 +139,7 @@ def create_repository(self, fields, privacy=DEFAULT_PRIVACY_LEVEL,
139139
repo.save()
140140
return repo
141141
else:
142-
log.debug('Not importing %s because mismatched type' %
142+
log.debug('Not importing %s because mismatched type',
143143
fields['name'])
144144

145145
def create_organization(self, fields):

readthedocs/oauth/services/github.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def create_repository(self, fields, privacy=DEFAULT_PRIVACY_LEVEL,
9494
)
9595
repo.users.add(self.user)
9696
if repo.organization and repo.organization != organization:
97-
log.debug('Not importing %s because mismatched orgs' %
97+
log.debug('Not importing %s because mismatched orgs',
9898
fields['name'])
9999
return None
100100
else:
@@ -116,7 +116,7 @@ def create_repository(self, fields, privacy=DEFAULT_PRIVACY_LEVEL,
116116
repo.save()
117117
return repo
118118
else:
119-
log.debug('Not importing %s because mismatched type' %
119+
log.debug('Not importing %s because mismatched type',
120120
fields['name'])
121121

122122
def create_organization(self, fields):
@@ -214,7 +214,6 @@ def setup_webhook(self, project):
214214
except (RequestException, ValueError):
215215
log.error('GitHub webhook creation failed for project: %s',
216216
project, exc_info=True)
217-
pass
218217
else:
219218
log.error('GitHub webhook creation failed for project: %s',
220219
project)
@@ -224,7 +223,7 @@ def setup_webhook(self, project):
224223
except ValueError:
225224
debug_data = resp.content
226225
log.debug('GitHub webhook creation failure response: %s',
227-
resp.json())
226+
debug_data)
228227
return (False, resp)
229228

230229
def update_webhook(self, project, integration):
@@ -259,15 +258,15 @@ def update_webhook(self, project, integration):
259258
except (RequestException, ValueError):
260259
log.error('GitHub webhook update failed for project: %s',
261260
project, exc_info=True)
262-
pass
263261
else:
264262
log.error('GitHub webhook update failed for project: %s',
265263
project)
266264
try:
267-
log.debug('GitHub webhook creation failure response: %s',
268-
resp.json())
265+
debug_data = resp.json()
269266
except ValueError:
270-
pass
267+
debug_data = resp.content
268+
log.debug('GitHub webhook creation failure response: %s',
269+
debug_data)
271270
return (False, resp)
272271

273272
@classmethod

readthedocs/oauth/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Support code for OAuth, including webhook support."""
12
import logging
23

34
from django.contrib import messages
@@ -36,7 +37,7 @@ def attach_webhook(project, request=None):
3637

3738
user_accounts = service.for_user(request.user)
3839
for account in user_accounts:
39-
success, resp = account.setup_webhook(project)
40+
success, __ = account.setup_webhook(project)
4041
if success:
4142
messages.success(request, _('Webhook activated'))
4243
project.has_valid_webhook = True

readthedocs/vcs_support/backends/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Listing of all the VCS backends."""
12
from . import bzr, hg, git, svn
23

34
backend_cls = {

readthedocs/vcs_support/backends/bzr.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Bazaar-related utilities."""
12
import csv
23
import re
34
import sys
@@ -12,6 +13,9 @@
1213

1314

1415
class Backend(BaseVCS):
16+
17+
"""Bazaar VCS backend."""
18+
1519
supports_tags = True
1620
fallback_branch = ''
1721

@@ -83,7 +87,7 @@ def parse_tags(self, data):
8387

8488
@property
8589
def commit(self):
86-
retcode, stdout = self.run('bzr', 'revno')[:2]
90+
_, stdout = self.run('bzr', 'revno')[:2]
8791
return stdout.strip()
8892

8993
def checkout(self, identifier=None):

readthedocs/vcs_support/backends/git.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Git-related utilities."""
12
import re
23
import logging
34
import csv
@@ -17,6 +18,9 @@
1718

1819

1920
class Backend(BaseVCS):
21+
22+
"""Git VCS backend."""
23+
2024
supports_tags = True
2125
supports_branches = True
2226
fallback_branch = 'master' # default branch
@@ -48,11 +52,11 @@ def update(self):
4852
self.checkout()
4953

5054
def repo_exists(self):
51-
code, out, err = self.run('git', 'status')
55+
code, _, _ = self.run('git', 'status')
5256
return code == 0
5357

5458
def fetch(self):
55-
code, out, err = self.run('git', 'fetch', '--tags', '--prune')
59+
code, _, err = self.run('git', 'fetch', '--tags', '--prune')
5660
if code != 0:
5761
raise ProjectImportError(
5862
"Failed to get code from '%s' (git fetch): %s\n\nStderr:\n\n%s\n\n" % (
@@ -67,13 +71,13 @@ def checkout_revision(self, revision=None):
6771
code, out, err = self.run('git', 'checkout',
6872
'--force', '--quiet', revision)
6973
if code != 0:
70-
log.warning("Failed to checkout revision '%s': %s" % (
71-
revision, code))
74+
log.warning("Failed to checkout revision '%s': %s",
75+
revision, code)
7276
return [code, out, err]
7377

7478
def clone(self):
75-
code, out, err = self.run('git', 'clone', '--recursive', '--quiet',
76-
self.repo_url, '.')
79+
code, _, err = self.run('git', 'clone', '--recursive', '--quiet',
80+
self.repo_url, '.')
7781
if code != 0:
7882
raise ProjectImportError(
7983
(
@@ -88,7 +92,7 @@ def clone(self):
8892

8993
@property
9094
def tags(self):
91-
retcode, stdout, err = self.run('git', 'show-ref', '--tags')
95+
retcode, stdout, _ = self.run('git', 'show-ref', '--tags')
9296
# error (or no tags found)
9397
if retcode != 0:
9498
return []
@@ -123,7 +127,7 @@ def parse_tags(self, data):
123127
@property
124128
def branches(self):
125129
# Only show remote branches
126-
retcode, stdout, err = self.run('git', 'branch', '-r')
130+
retcode, stdout, _ = self.run('git', 'branch', '-r')
127131
# error (or no tags found)
128132
if retcode != 0:
129133
return []
@@ -163,7 +167,7 @@ def parse_branches(self, data):
163167

164168
@property
165169
def commit(self):
166-
retcode, stdout, err = self.run('git', 'rev-parse', 'HEAD')
170+
_, stdout, _ = self.run('git', 'rev-parse', 'HEAD')
167171
return stdout.strip()
168172

169173
def checkout(self, identifier=None):
@@ -210,7 +214,7 @@ def find_ref(self, ref):
210214
return ref
211215

212216
def ref_exists(self, ref):
213-
code, out, err = self.run('git', 'show-ref', ref)
217+
code, _, _ = self.run('git', 'show-ref', ref)
214218
return code == 0
215219

216220
@property

readthedocs/vcs_support/backends/hg.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
"""Mercurial-related utilities."""
12
from readthedocs.projects.exceptions import ProjectImportError
23
from readthedocs.vcs_support.base import BaseVCS, VCSVersion
34

45

56
class Backend(BaseVCS):
7+
8+
"""Mercurial VCS backend."""
9+
610
supports_tags = True
711
supports_branches = True
812
fallback_branch = 'default'
@@ -85,13 +89,13 @@ def parse_tags(self, data):
8589
name, commit = row
8690
if name == 'tip':
8791
continue
88-
revision, commit_hash = commit.split(':')
92+
_, commit_hash = commit.split(':')
8993
vcs_tags.append(VCSVersion(self, commit_hash, name))
9094
return vcs_tags
9195

9296
@property
9397
def commit(self):
94-
retcode, stdout = self.run('hg', 'id', '-i')[:2]
98+
_, stdout = self.run('hg', 'id', '-i')[:2]
9599
return stdout.strip()
96100

97101
def checkout(self, identifier=None):

readthedocs/vcs_support/backends/svn.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Subversion-related utilities."""
12
import csv
23
import sys
34

@@ -11,6 +12,9 @@
1112

1213

1314
class Backend(BaseVCS):
15+
16+
"""Subversion VCS backend."""
17+
1418
supports_tags = False
1519
fallback_branch = '/trunk/'
1620

@@ -96,7 +100,7 @@ def parse_tags(self, data):
96100

97101
@property
98102
def commit(self):
99-
retcode, stdout = self.run('svnversion')[:2]
103+
_, stdout = self.run('svnversion')[:2]
100104
return stdout.strip()
101105

102106
def checkout(self, identifier=None):

readthedocs/vcs_support/base.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Base classes for VCS backends."""
12
import logging
23
import os
34
import shutil
@@ -90,6 +91,8 @@ class BaseVCS(BaseCLI):
9091
# General methods
9192
# =========================================================================
9293

94+
# Defining a base API, so we'll have unused args
95+
# pylint: disable=unused-argument
9396
def __init__(self, project, version, **kwargs):
9497
self.default_branch = project.default_branch
9598
self.name = project.name

readthedocs/vcs_support/utils.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Locking utilities."""
12
import logging
23
import os
34
import time
@@ -32,29 +33,29 @@ def __enter__(self):
3233
while os.path.exists(self.fpath):
3334
lock_age = time.time() - os.stat(self.fpath)[stat.ST_MTIME]
3435
if lock_age > self.timeout:
35-
log.info("Lock (%s): Force unlock, old lockfile" %
36+
log.info("Lock (%s): Force unlock, old lockfile",
3637
self.name)
3738
os.remove(self.fpath)
3839
break
39-
log.info("Lock (%s): Locked, waiting.." % self.name)
40+
log.info("Lock (%s): Locked, waiting..", self.name)
4041
time.sleep(self.polling_interval)
4142
timesince = time.time() - start
4243
if timesince > self.timeout:
43-
log.info("Lock (%s): Force unlock, timeout reached" %
44+
log.info("Lock (%s): Force unlock, timeout reached",
4445
self.name)
4546
os.remove(self.fpath)
4647
break
47-
log.info(("%s still locked after %.2f seconds; retry for %.2f"
48-
" seconds") % (self.name, timesince, self.timeout))
48+
log.info("%s still locked after %.2f seconds; retry for %.2f"
49+
" seconds", self.name, timesince, self.timeout)
4950
open(self.fpath, 'w').close()
50-
log.info("Lock (%s): Lock acquired" % self.name)
51+
log.info("Lock (%s): Lock acquired", self.name)
5152

5253
def __exit__(self, exc, value, tb):
5354
try:
54-
log.info("Lock (%s): Releasing" % self.name)
55+
log.info("Lock (%s): Releasing", self.name)
5556
os.remove(self.fpath)
56-
except:
57-
log.error("Lock (%s): Failed to release, ignoring..." % self.name,
57+
except OSError:
58+
log.error("Lock (%s): Failed to release, ignoring...", self.name,
5859
exc_info=True)
5960

6061

@@ -82,20 +83,20 @@ def __enter__(self):
8283
if path_exists and self.max_lock_age is not None:
8384
lock_age = time.time() - os.stat(self.fpath)[stat.ST_MTIME]
8485
if lock_age > self.max_lock_age:
85-
log.info("Lock (%s): Force unlock, old lockfile" %
86+
log.info("Lock (%s): Force unlock, old lockfile",
8687
self.name)
8788
os.remove(self.fpath)
8889
else:
89-
raise LockTimeout("Lock (%s): Lock still active" % self.name)
90+
raise LockTimeout("Lock (%s): Lock still active", self.name)
9091
elif path_exists:
91-
raise LockTimeout("Lock (%s): Lock still active" % self.name)
92+
raise LockTimeout("Lock (%s): Lock still active", self.name)
9293
open(self.fpath, 'w').close()
9394
return self
9495

9596
def __exit__(self, exc_type, exc_val, exc_tb):
9697
try:
97-
log.info("Lock (%s): Releasing" % self.name)
98+
log.info("Lock (%s): Releasing", self.name)
9899
os.remove(self.fpath)
99100
except (IOError, OSError):
100-
log.error("Lock (%s): Failed to release, ignoring..." % self.name,
101+
log.error("Lock (%s): Failed to release, ignoring...", self.name,
101102
exc_info=True)

0 commit comments

Comments
 (0)