Skip to content

Commit

Permalink
[Python] Follow standard Python docstrings conventions (PEP-0257).
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift committed Feb 20, 2016
1 parent 67fda25 commit e395ea0
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 26 deletions.
6 changes: 4 additions & 2 deletions benchmark/scripts/Benchmark_Driver
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def get_current_git_branch(git_repo_path):

def log_results(log_directory, driver, formatted_output, swift_repo=None):
"""Log `formatted_output` to a branch specific directory in
`log_directory`"""
`log_directory`
"""
try:
branch = get_current_git_branch(swift_repo)
except:
Expand All @@ -149,7 +150,8 @@ def run_benchmarks(driver, benchmarks=[], num_samples=10, verbose=False,
log_directory=None, swift_repo=None):
"""Run perf tests individually and return results in a format that's
compatible with `parse_results`. If `benchmarks` is not empty,
only run tests included in it."""
only run tests included in it.
"""
(total_tests, total_min, total_max, total_mean) = (0, 0, 0, 0)
output = []
headings = ['#', 'TEST', 'SAMPLES', 'MIN(μs)', 'MAX(μs)', 'MEAN(μs)',
Expand Down
9 changes: 2 additions & 7 deletions tools/SourceKit/bindings/python/sourcekitd/capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ def __hash__(self):
return hash(self._ptr())

class ErrorKind(object):
"""
Describes the kind of type.
"""
"""Describes the kind of type."""

# The unique kind objects, indexed by id.
_kinds = []
Expand Down Expand Up @@ -242,9 +240,7 @@ def applier(cobj, value, d):
return d

class VariantType(object):
"""
Describes the kind of type.
"""
"""Describes the kind of type."""

# The unique kind objects, indexed by id.
_kinds = []
Expand Down Expand Up @@ -542,7 +538,6 @@ def register_functions(lib, ignore_errors):
This must be called as part of library instantiation so Python knows how
to call out to the shared library.
"""

def register(item):
return register_function(lib, item, ignore_errors)

Expand Down
3 changes: 0 additions & 3 deletions utils/GYBUnicodeDataUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ def create_tables(self):
Don't change parameter values after calling this method.
"""

self.BMP_data_offset_bits = 16 - self.BMP_first_level_index_bits

self.supp_data_offset_bits = \
Expand Down Expand Up @@ -319,9 +318,7 @@ def freeze(self):
"""Compress internal trie representation.
Don't mutate the trie after calling this method.
"""

def remap_indexes(indexes, old_idx, new_idx):
def map_index(idx):
if idx == old_idx:
Expand Down
8 changes: 7 additions & 1 deletion utils/gyb.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def codeStartsWithDedentKeyword(sourceLines):

class ParseContext:
"""State carried through a parse of a template"""

filename = ''
template = ''
lineStarts = []
Expand All @@ -385,7 +386,7 @@ def posToLine(self, pos):
return bisect(self.lineStarts, pos) - 1

def tokenGenerator(self, baseTokens):
r""" Given an iterator over (kind, text, match) triples (see
r"""Given an iterator over (kind, text, match) triples (see
tokenizeTemplate above), return a refined iterator over
tokenKinds.
Expand Down Expand Up @@ -527,6 +528,7 @@ def nextToken(self):

class ExecutionContext:
"""State we pass around during execution of a template"""

def __init__(self, lineDirective='// ###line', **localBindings):
self.localBindings = localBindings
self.lineDirective = lineDirective
Expand Down Expand Up @@ -556,6 +558,7 @@ def appendText(self, text, file, line):

class ASTNode(object):
"""Abstract base class for template AST nodes"""

def __init__(self):
raise NotImplemented

Expand All @@ -577,6 +580,7 @@ def formatChildren(self, indent):

class Block(ASTNode):
"""A sequence of other AST nodes, to be executed in order"""

children = []

def __init__(self, context):
Expand All @@ -598,6 +602,7 @@ def __str__(self, indent=''):

class Literal(ASTNode):
"""An AST node that generates literal text"""

def __init__(self, context):
self.text = context.tokenText
startPosition = context.tokenMatch.start(context.tokenKind)
Expand All @@ -614,6 +619,7 @@ def __str__(self, indent=''):

class Code(ASTNode):
"""An AST node that is evaluated as Python"""

code = None
children = ()
kind = None
Expand Down
2 changes: 1 addition & 1 deletion utils/line-directive
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _make_line_map(filename, stream=None):
... line 7
... '''))
[(0, 'box', 1), (1, 'foo.bar', 3), (5, 'baz.txt', 20)]
"""
"""
result = [(0, filename, 1)]
input = stream or open(filename)
for i, l in enumerate(input.readlines()):
Expand Down
4 changes: 3 additions & 1 deletion utils/profdata_merge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

class Config():
"""A class to store configuration information specified by command-line
arguments."""
arguments.
"""

def __init__(self, out_dir, no_remove_files):
self.out_dir = out_dir
self.tmp_dir = tempfile.mkdtemp()
Expand Down
6 changes: 4 additions & 2 deletions utils/profdata_merge/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def merge_file_buffer(self):
"""Merge all files in this worker's buffer and clear them.
This method makes a copy of the working merge progress, then
calls llvm-cov merge with up to 10 filenames, plus the current
in-progress merge."""
in-progress merge.
"""
if not self.filename_buffer:
self.report("no files to merge...")
return
Expand All @@ -62,7 +63,8 @@ def merge_file_buffer(self):
def run(self):
"""Blocks and waits for the file queue so it can fill its buffer and
execute merges. If it finds None in the queue, then it knows to stop
waiting for the queue, merge its current buffer, and kill itself"""
waiting for the queue, merge its current buffer, and kill itself
"""
while True:
filename = self.file_queue.get()
self.report("received filename: %s" % filename)
Expand Down
3 changes: 2 additions & 1 deletion utils/profdata_merge/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def report(self, msg):
def handle(self):
"""Receive a newline-separated list of filenames from a TCP connection
and add them to the shared merge queue, where the workers will
execute llvm-profdata merge commands."""
execute llvm-profdata merge commands.
"""
data = self.rfile.read()
self.report("received data (length %d): %s" % (len(data), repr(data)))

Expand Down
10 changes: 5 additions & 5 deletions utils/submit-benchmark-results
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python

"""
Utility script for submitting benchmark results to an LNT server.
"""
"""Utility script for submitting benchmark results to an LNT server."""

from __future__ import print_function

Expand All @@ -27,7 +25,8 @@ def capture_with_result(args, include_stderr=False):
"""capture_with_result(command) -> (output, exit code)
Run the given command (or argv list) in a shell and return the standard
output and exit code."""
output and exit code.
"""
stderr = subprocess.PIPE
if include_stderr:
stderr = subprocess.STDOUT
Expand All @@ -44,7 +43,8 @@ def capture_with_result(args, include_stderr=False):

def capture(args, include_stderr=False):
"""capture(command) - Run the given command (or argv list) in a shell and
return the standard output."""
return the standard output.
"""
return capture_with_result(args, include_stderr)[0]


Expand Down
4 changes: 1 addition & 3 deletions utils/swift_build_support/swift_build_support/ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@


def is_ninja_installed():
"""
Return whether `ninja` or `ninja-build` are available on the host machine.
"""
"""Return whether `ninja` or `ninja-build` are available on the host machine."""
if which('ninja') or which('ninja-build'):
return True
else:
Expand Down

0 comments on commit e395ea0

Please sign in to comment.