Skip to content

Commit

Permalink
respond to feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
baroquebobcat committed Apr 7, 2015
1 parent ddab60e commit a7ead6d
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/python/pants/backend/core/tasks/group_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def group_name(self):
if group_task.product_types() != product_type:
raise ValueError('The group {!r} was already registered with product type: {!r} - refusing to '
'overwrite with new product type: {!r}'.format(name, group_task.product_types(),
product_type))
product_type))

return group_task

Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/jvm/tasks/bootstrap_jvm_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def bootstrap_classpath():
with cache_lock:
if 'classpath' not in cache:
targets = list(self._resolve_tool_targets(tools, key, scope))
workunit_name = 'bootstrap-{!s}'.format(key)
workunit_name = 'bootstrap-{}'.format(key)
cache['classpath'] = self.ivy_resolve(targets,
silent=True,
workunit_name=workunit_name)[0]
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/jvm/tasks/detect_duplicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _log_conflicts(self, conflicts_by_artifacts, target):
for artifacts, duplicate_files in conflicts_by_artifacts.items():
if len(artifacts) < 2: continue
self.context.log.warn(
'Duplicate classes and/or resources detected in artifacts: {!s}'.format(artifacts))
'Duplicate classes and/or resources detected in artifacts: {}'.format(artifacts))
dup_list = list(duplicate_files)
for duplicate_file in dup_list[:self._max_dups]:
self.context.log.warn(' {}'.format(duplicate_file))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ def get(self, key, default=None):
return self.mappings.get(key, default)

def __str__(self):
return "ResourceMapping({!s})".format(self.mappings)
return "ResourceMapping({})".format(self.mappings)
3 changes: 2 additions & 1 deletion src/python/pants/backend/python/thrift_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def collect_sources(target):

for src in copied_sources:
if not self._run_thrift(src):
raise PythonThriftBuilder.CodeGenerationException("Could not generate .py from {}!".format(src))
raise PythonThriftBuilder.CodeGenerationException(
"Could not generate .py from {}!".format(src))

def _run_thrift(self, source):
args = [
Expand Down
14 changes: 9 additions & 5 deletions src/python/pants/base/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ def assert_list(obj, expected_type=string_types, can_be_none=True, default=(),
if can_be_none:
val = list(default)
else:
raise raise_type('Expected an object of acceptable type {}, received None and can_be_none is False'
.format(allowable))
raise raise_type(
'Expected an object of acceptable type {}, received None and can_be_none is False'
.format(allowable))

if [typ for typ in allowable if isinstance(val, typ)]:
lst = list(val)
for e in lst:
if not isinstance(e, expected_type):
raise raise_type('Expected a list containing values of type {}, instead got a value {} of {}'
.format(expected_type, e, e.__class__))
raise raise_type(
'Expected a list containing values of type {}, instead got a value {} of {}'
.format(expected_type, e, e.__class__))
return lst
else:
raise raise_type('Expected an object of acceptable type {}, received {} instead'.format(allowable, val))
raise raise_type(
'Expected an object of acceptable type {}, received {} instead'
.format(allowable, val))
4 changes: 2 additions & 2 deletions src/python/pants/base/worker_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def done():

def error(e):
done()
self._run_tracker.log(Report.ERROR, '{!s}'.format(e))
self._run_tracker.log(Report.ERROR, '{}'.format(e))

# We filter out Nones defensively. There shouldn't be any, but if a bug causes one,
# Pants might hang indefinitely without this filtering.
Expand All @@ -112,7 +112,7 @@ def submit_next():
submit_next()
except Exception as e: # Handles errors in the submission code.
done()
self._run_tracker.log(Report.ERROR, '{!s}'.format(e))
self._run_tracker.log(Report.ERROR, '{}'.format(e))
raise

def submit_work_and_wait(self, work, workunit_parent=None):
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/bin/pants_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def unhandled_exception_hook(self, exception_class, exception, tb):
if self._is_print_backtrace:
msg = '\nException caught:\n' + ''.join(self._format_tb(tb))
if str(exception):
msg += '\nException message: {!s}\n'.format(exception)
msg += '\nException message: {}\n'.format(exception)
else:
msg += '\nNo specific exception message.\n'
# TODO(Jin Feng) Always output the unhandled exception details into a log file.
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/cache/cache_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def select_best_url(spec, pinger, log):
netlocs = map(lambda url: urlparse.urlparse(url)[1], urls)
pingtimes = pinger.pings(netlocs) # List of pairs (host, time in ms).
log.debug('Artifact cache server ping times: {}'
.format(', '.join(['{}: {:3} secs'.format(*p) for p in pingtimes])))
.format(', '.join(['{}: {:.6f} secs'.format(*p) for p in pingtimes])))
argmin = min(range(len(pingtimes)), key=lambda i: pingtimes[i][1])
best_url = urls[argmin]
if pingtimes[argmin][1] == Pinger.UNREACHABLE:
Expand Down
8 changes: 4 additions & 4 deletions src/python/pants/java/distribution/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ def search_path():
dist = cls(bin_path=path, minimum_version=minimum_version,
maximum_version=maximum_version, jdk=jdk)
dist.validate()
logger.debug('Located {} for constraints: minimum_version {}, '
'maximum_version {}, jdk {}'.format(dist, minimum_version, maximum_version, jdk))
logger.debug('Located {} for constraints: minimum_version {}, maximum_version {}, jdk {}'
.format(dist, minimum_version, maximum_version, jdk))
return dist
except (ValueError, cls.Error):
pass

raise cls.Error('Failed to locate a {} distribution with minimum_version {}, maximum_version {}'.format(
'JDK' if jdk else 'JRE', minimum_version, maximum_version))
raise cls.Error('Failed to locate a {} distribution with minimum_version {}, maximum_version {}'
.format('JDK' if jdk else 'JRE', minimum_version, maximum_version))

@staticmethod
def _parse_java_version(name, version):
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/net/http/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def recv_chunk(self, data):

def finished(self):
if self.chunks > 0:
sys.stdout.write(' {:.3}s\n'.format(time.time() - self._start))
sys.stdout.write(' {:.3f}s\n'.format(time.time() - self._start))
sys.stdout.flush()

def __init__(self, requests_api=None):
Expand Down
6 changes: 3 additions & 3 deletions src/python/pants/reporting/html_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ def end_workunit(self, workunit):
"""Implementation of Reporter callback."""
# Create the template arguments.
duration = workunit.duration()
timing = '{:.3}'.format(duration)
timing = '{:.3f}'.format(duration)
unaccounted_time = None
# Background work may be idle a lot, no point in reporting that as unaccounted.
if self.is_under_main_root(workunit):
unaccounted_time_secs = workunit.unaccounted_time()
if unaccounted_time_secs >= 1 and unaccounted_time_secs > 0.05 * duration:
unaccounted_time = '{:.3}'.format(unaccounted_time_secs)
unaccounted_time = '{:.3f}'.format(unaccounted_time_secs)
args = { 'workunit': workunit.to_dict(),
'status': HtmlReporter._outcome_css_classes[workunit.outcome()],
'timing': timing,
Expand All @@ -139,7 +139,7 @@ def end_workunit(self, workunit):
def render_timings(timings):
timings_dict = timings.get_all()
for item in timings_dict:
item['timing_string'] = '{:.3}'.format(item['timing'])
item['timing_string'] = '{:.3f}'.format(item['timing'])
args = {
'timings': timings_dict
}
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/reporting/plaintext_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _show_output_unindented(self, workunit):
return workunit.has_label(WorkUnit.REPL) or workunit.has_label(WorkUnit.RUN)

def _format_aggregated_timings(self, aggregated_timings):
return b'\n'.join([b'{timing:.3} {label}'.format(**x) for x in aggregated_timings.get_all()])
return b'\n'.join([b'{timing:.3f} {label}'.format(**x) for x in aggregated_timings.get_all()])

def _format_artifact_cache_stats(self, artifact_cache_stats):
stats = artifact_cache_stats.get_all()
Expand Down

0 comments on commit a7ead6d

Please sign in to comment.