diff --git a/agate/mapped_sequence.py b/agate/mapped_sequence.py index 7878d621..b87f215f 100644 --- a/agate/mapped_sequence.py +++ b/agate/mapped_sequence.py @@ -65,7 +65,7 @@ def __unicode__(self): if len(self) > 5: sample = '%s, ...' % sample - return ''.format(type(self).__name__, sample) + return f'' def __str__(self): """ diff --git a/agate/table/__init__.py b/agate/table/__init__.py index 8cb3b121..638c6b55 100644 --- a/agate/table/__init__.py +++ b/agate/table/__init__.py @@ -130,7 +130,7 @@ def __init__(self, rows, column_names=None, column_types=None, row_names=None, _ try: row_values.append(cast_funcs[j](d)) except CastError as e: - raise CastError(str(e) + ' Error at row {} column {}.'.format(i, self._column_names[j])) + raise CastError(str(e) + f' Error at row {i} column {self._column_names[j]}.') new_rows.append(Row(row_values, self._column_names)) else: diff --git a/agate/table/bins.py b/agate/table/bins.py index 1f35c3cd..78608792 100644 --- a/agate/table/bins.py +++ b/agate/table/bins.py @@ -63,7 +63,7 @@ def name_bin(i, j, first_exclusive=True, last_exclusive=False): exclusive = format_decimal(j, format=break_formatter) output = '[' if first_exclusive else '(' - output += '{} - {}'.format(inclusive, exclusive) + output += f'{inclusive} - {exclusive}' output += ']' if last_exclusive else ')' return output diff --git a/agate/table/print_bars.py b/agate/table/print_bars.py index 23f89348..25dc3a2d 100644 --- a/agate/table/print_bars.py +++ b/agate/table/print_bars.py @@ -175,7 +175,7 @@ def write(line): output.write(line + '\n') # Chart top - top_line = '{} {}'.format(y_label.ljust(max_label_width), x_label.rjust(max_value_width)) + top_line = f'{y_label.ljust(max_label_width)} {x_label.rjust(max_value_width)}' write(top_line) # Bars @@ -210,7 +210,7 @@ def write(line): bar = bar.ljust(plot_width) - write('{} {} {}'.format(label_text, value_text, bar)) + write(f'{label_text} {value_text} {bar}') # Axis & ticks axis = horizontal_line * plot_width diff --git a/agate/table/print_table.py b/agate/table/print_table.py index 0ad5c5af..6d502f5a 100644 --- a/agate/table/print_table.py +++ b/agate/table/print_table.py @@ -137,7 +137,7 @@ def write_row(formatted_row): text = v_line.join(row_output) - write('{}{}{}'.format(v_line, text, v_line)) + write(f'{v_line}{text}{v_line}') divider = '{v_line} {columns} {v_line}'.format( v_line=v_line, diff --git a/tests/test_py3.py b/tests/test_py3.py index f3a561a5..c50f4ea1 100644 --- a/tests/test_py3.py +++ b/tests/test_py3.py @@ -240,5 +240,5 @@ def test_sniffer(self): actual = csv_py3.Sniffer().sniff(contents).__dict__ expected = csv.Sniffer().sniff(contents).__dict__ - self.assertEqual(direct, expected, '{!r} != {!r}'.format(direct, expected)) - self.assertEqual(actual, expected, '{!r} != {!r}'.format(actual, expected)) + self.assertEqual(direct, expected, f'{direct!r} != {expected!r}') + self.assertEqual(actual, expected, f'{actual!r} != {expected!r}')