Skip to content

Commit ec36b57

Browse files
committed
[QA] Follow PEP 257 whitespace rules.
1 parent 3a82036 commit ec36b57

12 files changed

Lines changed: 131 additions & 29 deletions

github2/bin/manage_collaborators.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
def print_(text):
2727
"""Python 2 & 3 compatible print function
2828
29-
We support <2.6, so can't use __future__.print_function"""
29+
We support <2.6, so can't use __future__.print_function
30+
31+
"""
3032
if PY3K:
3133
print(text)
3234
else:

github2/bin/search_repos.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
def print_(text):
2020
"""Python 2 & 3 compatible print function
2121
22-
We support <2.6, so can't use __future__.print_function"""
22+
We support <2.6, so can't use __future__.print_function
23+
24+
"""
2325
if PY3K:
2426
print(text)
2527
else:

github2/client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class Github(object):
1313
def __init__(self, username=None, api_token=None, requests_per_second=None,
1414
access_token=None, cache=None, proxy_host=None,
1515
proxy_port=8080, github_url=None):
16-
"""
17-
An interface to GitHub's API:
16+
"""An interface to GitHub's API:
1817
http://develop.github.com/
1918
2019
.. versionadded:: 0.2.0
@@ -42,6 +41,7 @@ def __init__(self, username=None, api_token=None, requests_per_second=None,
4241
default to 8080 if a proxy_host is set and no port is set).
4342
:param str github_url: the hostname to connect to, for GitHub
4443
Enterprise support
44+
4545
"""
4646

4747
self.request = GithubRequest(username=username, api_token=api_token,
@@ -63,6 +63,7 @@ def project_for_user_repo(self, user, repo):
6363
6464
:param str user: repository owner
6565
:param str repo: repository name
66+
6667
"""
6768
return "/".join([user, repo])
6869

@@ -73,6 +74,7 @@ def get_all_blobs(self, project, tree_sha):
7374
7475
:param str project: GitHub project
7576
:param str tree_sha: object ID of tree
77+
7678
"""
7779
blobs = self.request.get("blob/all", project, tree_sha)
7880
return blobs.get("blobs")
@@ -83,6 +85,7 @@ def get_blob_info(self, project, tree_sha, path):
8385
:param str project: GitHub project
8486
:param str tree_sha: object ID of tree
8587
:param str path: path within tree to fetch blob for
88+
8689
"""
8790
blob = self.request.get("blob/show", project, tree_sha, path)
8891
return blob.get("blob")
@@ -92,6 +95,7 @@ def get_tree(self, project, tree_sha):
9295
9396
:param str project: GitHub project
9497
:param str tree_sha: object ID of tree
98+
9599
"""
96100
tree = self.request.get("tree/show", project, tree_sha)
97101
return tree.get("tree", [])
@@ -100,6 +104,7 @@ def get_network_meta(self, project):
100104
"""Get GitHub metadata associated with a project
101105
102106
:param str project: GitHub project
107+
103108
"""
104109
return self.request.raw_request("/".join([self.request.github_url,
105110
project,
@@ -112,6 +117,7 @@ def get_network_data(self, project, nethash, start=None, end=None):
112117
:param str nethash: identifier provided by :meth:`get_network_meta`
113118
:param int start: optional start point for data
114119
:param int stop: optional end point for data
120+
115121
"""
116122
data = {"nethash": nethash}
117123
if start:

github2/commits.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def list(self, project, branch="master", file=None, page=1):
3939
:param str branch: branch name, or ``master`` if not given
4040
:param str file: optional file filter
4141
:param int page: optional page number
42+
4243
"""
4344
return self.get_values("list", project, branch, file, filter="commits",
4445
datatype=Commit, page=page)
@@ -48,6 +49,7 @@ def show(self, project, sha):
4849
4950
:param str project: project name
5051
:param str sha: commit id
52+
5153
"""
5254
return self.get_value("show", project, sha,
5355
filter="commit", datatype=Commit)

github2/core.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def string_to_datetime(string):
3030
"""Convert a string to Python datetime
3131
3232
:param str github_date: date string to parse
33+
3334
"""
3435
parsed = parser.parse(string)
3536
if NAIVE:
@@ -41,6 +42,7 @@ def _handle_naive_datetimes(f):
4142
"""Decorator to make datetime arguments use GitHub timezone
4243
4344
:param func f: Function to wrap
45+
4446
"""
4547
def wrapper(datetime_):
4648
if not datetime_.tzinfo:
@@ -62,6 +64,7 @@ def datetime_to_ghdate(datetime_):
6264
"""Convert Python datetime to GitHub date string
6365
6466
:param datetime datetime_: datetime object to convert
67+
6568
"""
6669
return datetime_.strftime(GITHUB_DATE_FORMAT)
6770

@@ -71,6 +74,7 @@ def datetime_to_commitdate(datetime_):
7174
"""Convert Python datetime to GitHub date string
7275
7376
:param datetime datetime_: datetime object to convert
77+
7478
"""
7579
date_without_tz = datetime_.strftime(COMMIT_DATE_FORMAT)
7680
utcoffset = GITHUB_TZ.utcoffset(datetime_)
@@ -95,7 +99,8 @@ def datetime_to_isodate(datetime_):
9599

96100

97101
class AuthError(Exception):
98-
"""Requires authentication"""
102+
103+
"""Requires authentication."""
99104

100105

101106
def requires_auth(f):
@@ -105,6 +110,7 @@ def requires_auth(f):
105110
106111
:param func f: Function to wrap
107112
:raises AuthError: If function called without an authenticated session
113+
108114
"""
109115
# When Python 2.4 support is dropped move straight to functools.wraps,
110116
# don't pass go and don't collect $200.
@@ -129,6 +135,7 @@ def enhanced_by_auth(f):
129135
introspection.
130136
131137
:param func f: Function to wrap
138+
132139
"""
133140
f.enhanced_by_auth = True
134141
f.__doc__ += """\n.. note:: This call is enhanced with authentication"""
@@ -141,6 +148,7 @@ def __init__(self, request):
141148
"""Main API binding interface
142149
143150
:param github2.request.GithubRequest request: HTTP request handler
151+
144152
"""
145153
self.request = request
146154

@@ -155,6 +163,7 @@ def make_request(self, command, *args, **kwargs):
155163
data
156164
* The value of a ``page`` argument will be used to fetch a specific
157165
page of results, default of 1 is assumed if not given
166+
158167
"""
159168
filter = kwargs.get("filter")
160169
post_data = kwargs.get("post_data") or {}
@@ -182,6 +191,7 @@ def get_value(self, *args, **kwargs):
182191
183192
If a ``datatype`` parameter is given it defines the
184193
:class:`BaseData`-derived class we should build from the provided data
194+
185195
"""
186196
datatype = kwargs.pop("datatype", None)
187197
value = self.make_request(*args, **kwargs)
@@ -200,6 +210,7 @@ def get_values(self, *args, **kwargs):
200210
"""Process a multi-value response from the API
201211
202212
:see: :meth:`get_value`
213+
203214
"""
204215
datatype = kwargs.pop("datatype", None)
205216
values = self.make_request(*args, **kwargs)
@@ -221,6 +232,7 @@ def doc_generator(docstring, attributes):
221232
222233
:param str docstring: docstring to augment
223234
:param dict attributes: attributes to add to docstring
235+
224236
"""
225237
docstring = docstring or ""
226238

@@ -237,6 +249,7 @@ def __init__(self, help):
237249
"""Generic object attribute for use with :class:`BaseData`
238250
239251
:param str help: Attribute description
252+
240253
"""
241254
self.help = help
242255

@@ -260,6 +273,7 @@ def __init__(self, *args, **kwargs):
260273
261274
:param str format: The date format to support, see
262275
:data:`convertor_for_format` for supported options
276+
263277
"""
264278
self.format = kwargs.pop("format", self.format)
265279
super(DateAttribute, self).__init__(*args, **kwargs)
@@ -318,12 +332,15 @@ class BaseData(BaseDataType('BaseData', (object, ), {})):
318332
.. warning::
319333
Supports subscript attribute access purely for backwards compatibility,
320334
you shouldn't rely on that functionality in new code
335+
321336
"""
337+
322338
def __getitem__(self, key):
323339
"""Access objects's attribute using subscript notation
324340
325341
This is here purely to maintain compatibility when switching ``dict``
326342
responses to ``BaseData`` derived objects.
343+
327344
"""
328345
LOGGER.warning("Subscript access on %r is deprecated, use object "
329346
"attributes" % self.__class__.__name__,
@@ -336,6 +353,7 @@ def __setitem__(self, key, value):
336353
"""Update object's attribute using subscript notation
337354
338355
:see: :meth:`BaseData.__getitem__`
356+
339357
"""
340358
LOGGER.warning("Subscript access on %r is deprecated, use object "
341359
"attributes" % self.__class__.__name__,
@@ -350,6 +368,7 @@ def repr_string(string):
350368
351369
:param str string: string to operate on
352370
:return: string, with maximum length of 20 characters
371+
353372
"""
354373
if len(string) > 20:
355374
string = string[:17] + '...'

github2/issues.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def search(self, project, term, state="open"):
4949
:param str project: GitHub project
5050
:param str term: term to search issues for
5151
:param str state: can be either ``open`` or ``closed``.
52+
5253
"""
5354
return self.get_values("search", project, state, quote_plus(term),
5455
filter="issues", datatype=Issue)
@@ -58,6 +59,7 @@ def list(self, project, state="open"):
5859
5960
:param str project: GitHub project
6061
:param str state: can be either ``open`` or ``closed``.
62+
6163
"""
6264
return self.get_values("list", project, state, filter="issues",
6365
datatype=Issue)
@@ -69,6 +71,7 @@ def list_by_label(self, project, label):
6971
7072
:param str project: GitHub project
7173
:param str label: a string representing a label (e.g., ``bug``).
74+
7275
"""
7376
return self.get_values("list", project, "label", label,
7477
filter="issues", datatype=Issue)
@@ -79,14 +82,16 @@ def list_labels(self, project):
7982
.. versionadded:: 0.3.0
8083
8184
:param str project: GitHub project
85+
8286
"""
8387
return self.get_values("labels", project, filter="labels")
8488

8589
def show(self, project, number):
8690
"""Get all the data for issue by issue-number.
8791
8892
:param str project: GitHub project
89-
:param int number: issue number in the GitHub database
93+
:param int number: issue number in the Github database
94+
9095
"""
9196
return self.get_value("show", project, str(number),
9297
filter="issue", datatype=Issue)
@@ -98,6 +103,7 @@ def open(self, project, title, body):
98103
:param str project: GitHub project
99104
:param str title: title for issue
100105
:param str body: body for issue
106+
101107
"""
102108
issue_data = {"title": title, "body": body}
103109
return self.get_value("open", project, post_data=issue_data,
@@ -108,7 +114,8 @@ def close(self, project, number):
108114
"""Close an issue
109115
110116
:param str project: GitHub project
111-
:param int number: issue number in the GitHub database
117+
:param int number: issue number in the Github database
118+
112119
"""
113120
return self.get_value("close", project, str(number), filter="issue",
114121
datatype=Issue, method="POST")
@@ -120,7 +127,8 @@ def reopen(self, project, number):
120127
.. versionadded:: 0.3.0
121128
122129
:param str project: GitHub project
123-
:param int number: issue number in the GitHub database
130+
:param int number: issue number in the Github database
131+
124132
"""
125133
return self.get_value("reopen", project, str(number), filter="issue",
126134
datatype=Issue, method="POST")
@@ -135,6 +143,7 @@ def edit(self, project, number, title, body):
135143
:param int number: issue number in the GitHub database
136144
:param str title: title for issue
137145
:param str body: body for issue
146+
138147
"""
139148
issue_data = {"title": title, "body": body}
140149
return self.get_value("edit", project, str(number),
@@ -148,6 +157,7 @@ def add_label(self, project, number, label):
148157
:param str project: GitHub project
149158
:param int number: issue number in the GitHub database
150159
:param str label: label to attach to issue
160+
151161
"""
152162
return self.get_values("label/add", project, label, str(number),
153163
filter="labels", method="POST")
@@ -159,6 +169,7 @@ def remove_label(self, project, number, label):
159169
:param str project: GitHub project
160170
:param int number: issue number in the GitHub database
161171
:param str label: label to remove from issue
172+
162173
"""
163174
return self.get_values("label/remove", project, label, str(number),
164175
filter="labels", method="POST")
@@ -170,6 +181,7 @@ def comment(self, project, number, comment):
170181
:param str project: GitHub project
171182
:param int number: issue number in the GitHub database
172183
:param str comment: comment to attach to issue
184+
173185
"""
174186
comment_data = {'comment': comment}
175187
return self.get_value("comment", project, str(number),
@@ -180,7 +192,7 @@ def comments(self, project, number):
180192
"""View comments on an issue.
181193
182194
:param str project: GitHub project
183-
:param int number: issue number in the GitHub database
195+
184196
"""
185197
return self.get_values("comments", project, str(number),
186198
filter="comments", datatype=Comment)

0 commit comments

Comments
 (0)