Skip to content

Commit 661d213

Browse files
committed
Autolint cleanup for #3821
Pre PR autolinting
1 parent 673bfc7 commit 661d213

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

.isort.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ indent=' '
44
multi_line_output=4
55
default_section=THIRDPARTY
66
known_first_party=readthedocs,readthedocsinc
7-
known_third_party=mock
7+
known_third_party=mock,builtins
88
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
99
add_imports=from __future__ import division, from __future__ import print_function, from __future__ import unicode_literals

readthedocs/vcs_support/backends/git.py

+30-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# -*- coding: utf-8 -*-
12
"""Git-related utilities."""
23

3-
from __future__ import absolute_import
4+
from __future__ import (
5+
absolute_import, division, print_function, unicode_literals)
46

57
import csv
68
import logging
@@ -13,7 +15,6 @@
1315
from readthedocs.projects.exceptions import RepositoryError
1416
from readthedocs.vcs_support.base import BaseVCS, VCSVersion
1517

16-
1718
log = logging.getLogger(__name__)
1819

1920

@@ -39,9 +40,8 @@ def _get_clone_url(self):
3940
clone_url = 'https://%s@%s' % (self.token, hacked_url)
4041
return clone_url
4142
# Don't edit URL because all hosts aren't the same
42-
4343
# else:
44-
# clone_url = 'git://%s' % (hacked_url)
44+
# clone_url = 'git://%s' % (hacked_url)
4545
return self.repo_url
4646

4747
def set_remote_url(self, url):
@@ -69,22 +69,24 @@ def checkout_revision(self, revision=None):
6969
branch = self.default_branch or self.fallback_branch
7070
revision = 'origin/%s' % branch
7171

72-
code, out, err = self.run(
73-
'git', 'checkout', '--force', revision)
72+
code, out, err = self.run('git', 'checkout', '--force', revision)
7473
if code != 0:
75-
log.warning("Failed to checkout revision '%s': %s",
76-
revision, code)
74+
log.warning("Failed to checkout revision '%s': %s", revision, code)
7775
return [code, out, err]
7876

7977
def clone(self):
80-
code, _, _ = self.run(
81-
'git', 'clone', '--recursive', self.repo_url, '.')
78+
code, _, _ = self.run('git', 'clone', '--recursive', self.repo_url, '.')
8279
if code != 0:
8380
raise RepositoryError
8481

8582
@property
8683
def tags(self):
87-
retcode, stdout, _ = self.run('git', 'show-ref', '--tags', record_as_success=True)
84+
retcode, stdout, _ = self.run(
85+
'git',
86+
'show-ref',
87+
'--tags',
88+
record_as_success=True,
89+
)
8890
# error (or no tags found)
8991
if retcode != 0:
9092
return []
@@ -122,15 +124,20 @@ def parse_tags(self, data):
122124
@property
123125
def branches(self):
124126
# Only show remote branches
125-
retcode, stdout, _ = self.run('git', 'branch', '-r', record_as_success=True)
127+
retcode, stdout, _ = self.run(
128+
'git',
129+
'branch',
130+
'-r',
131+
record_as_success=True,
132+
)
126133
# error (or no branches found)
127134
if retcode != 0:
128135
return []
129136
return self.parse_branches(stdout)
130137

131138
def parse_branches(self, data):
132139
"""
133-
Parse output of git branch -r
140+
Parse output of git branch -r.
134141
135142
e.g.:
136143
@@ -155,7 +162,8 @@ def parse_branches(self, data):
155162
verbose_name = branch.replace('origin/', '')
156163
if verbose_name in ['HEAD']:
157164
continue
158-
clean_branches.append(VCSVersion(self, branch, verbose_name))
165+
clean_branches.append(
166+
VCSVersion(self, branch, verbose_name))
159167
else:
160168
clean_branches.append(VCSVersion(self, branch, branch))
161169
return clean_branches
@@ -193,8 +201,14 @@ def checkout(self, identifier=None):
193201
# Update submodules
194202
if self.submodules_exists():
195203
self.run('git', 'submodule', 'sync')
196-
self.run('git', 'submodule', 'update',
197-
'--init', '--recursive', '--force')
204+
self.run(
205+
'git',
206+
'submodule',
207+
'update',
208+
'--init',
209+
'--recursive',
210+
'--force',
211+
)
198212

199213
return code, out, err
200214

readthedocs/vcs_support/base.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# -*- coding: utf-8 -*-
2-
32
"""Base classes for VCS backends."""
4-
from __future__ import absolute_import
5-
from builtins import object
3+
from __future__ import (
4+
absolute_import, division, print_function, unicode_literals)
5+
66
import logging
77
import os
88
import shutil
99

10+
from builtins import object
1011

1112
log = logging.getLogger(__name__)
1213

@@ -28,8 +29,8 @@ def __init__(self, repository, identifier, verbose_name):
2829
self.verbose_name = verbose_name
2930

3031
def __repr__(self):
31-
return "<VCSVersion: %s:%s" % (self.repository.repo_url,
32-
self.verbose_name)
32+
return '<VCSVersion: %s:%s' % (
33+
self.repository.repo_url, self.verbose_name)
3334

3435

3536
class BaseVCS(object):
@@ -66,7 +67,7 @@ def check_working_dir(self):
6667
os.makedirs(self.working_dir)
6768

6869
def make_clean_working_dir(self):
69-
"""Ensures that the working dir exists and is empty"""
70+
"""Ensures that the working dir exists and is empty."""
7071
shutil.rmtree(self.working_dir, ignore_errors=True)
7172
self.check_working_dir()
7273

0 commit comments

Comments
 (0)