Skip to content

Commit

Permalink
Upgrade Python syntax with pyupgrade --py36-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Aug 12, 2022
1 parent fed762d commit d0ce0fa
Show file tree
Hide file tree
Showing 41 changed files with 75 additions and 75 deletions.
4 changes: 2 additions & 2 deletions dev/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
source_suffix = '.rst'
master_doc = 'index'

project = u'XlsxWriter'
copyright = u'2013-2022, John McNamara'
project = 'XlsxWriter'
copyright = '2013-2022, John McNamara'

version = '3.0.3'
release = version
Expand Down
6 changes: 3 additions & 3 deletions dev/performance/perf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ def time_openpyxl(optimised=False):

print("")
print("Versions:")
print("%s: %s" % ('python', str(sys.version).split()[0]))
print("%s: %s" % ('openpyxl', openpyxl.__version__))
print("%s: %s" % ('xlsxwriter', xlsxwriter.__version__))
print("{}: {}".format('python', str(sys.version).split()[0]))
print("{}: {}".format('openpyxl', openpyxl.__version__))
print("{}: {}".format('xlsxwriter', xlsxwriter.__version__))
print("")

print("Dimensions:")
Expand Down
4 changes: 2 additions & 2 deletions examples/inheritance1.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def write(self, row, col, *args):
return self.write_string(row, col, data)
else:
# Call the parent version of write() as usual for other data.
return super(MyWorksheet, self).write(row, col, *args)
return super().write(row, col, *args)


class MyWorkbook(Workbook):
Expand All @@ -41,7 +41,7 @@ class MyWorkbook(Workbook):

def add_worksheet(self, name=None):
# Overwrite add_worksheet() to create a MyWorksheet object.
worksheet = super(MyWorkbook, self).add_worksheet(name, MyWorksheet)
worksheet = super().add_worksheet(name, MyWorksheet)

return worksheet

Expand Down
6 changes: 3 additions & 3 deletions examples/inheritance2.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def write_string(self, row, col, string, cell_format=None):
self.max_column_widths[col] = string_width

# Now call the parent version of write_string() as usual.
return super(MyWorksheet, self).write_string(row, col, string,
return super().write_string(row, col, string,
cell_format)


Expand All @@ -77,7 +77,7 @@ class MyWorkbook(Workbook):
def add_worksheet(self, name=None):
# Overwrite add_worksheet() to create a MyWorksheet object.
# Also add an Worksheet attribute to store the column widths.
worksheet = super(MyWorkbook, self).add_worksheet(name, MyWorksheet)
worksheet = super().add_worksheet(name, MyWorksheet)
worksheet.max_column_widths = {}

return worksheet
Expand All @@ -91,7 +91,7 @@ def close(self):
for column, width in worksheet.max_column_widths.items():
worksheet.set_column(column, column, width)

return super(MyWorkbook, self).close()
return super().close()


# Create a new MyWorkbook object.
Expand Down
2 changes: 1 addition & 1 deletion examples/unicode_polish_utf8.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import xlsxwriter

# Open the input file with the correct encoding.
textfile = open('unicode_polish_utf8.txt', mode='r', encoding='utf-8')
textfile = open('unicode_polish_utf8.txt', encoding='utf-8')

# Create an new Excel file and convert the text data.
workbook = xlsxwriter.Workbook('unicode_polish_utf8.xlsx')
Expand Down
2 changes: 1 addition & 1 deletion examples/unicode_shift_jis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import xlsxwriter

# Open the input file with the correct encoding.
textfile = open('unicode_shift_jis.txt', mode='r', encoding='shift_jis')
textfile = open('unicode_shift_jis.txt', encoding='shift_jis')

# Create an new Excel file and convert the text data.
workbook = xlsxwriter.Workbook('unicode_shift_jis.xlsx')
Expand Down
4 changes: 2 additions & 2 deletions examples/vba_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
vba_file.write(vba_data)
vba_file.close()

except IOError as e:
except OSError as e:
print("File error: %s" % str(e))
exit()

Expand All @@ -51,7 +51,7 @@

except BadZipfile as e:
# Usually if the file is an xls file and not an xlsm file.
print("File error: %s: '%s'" % (str(e), xlsm_file))
print("File error: {}: '{}'".format(str(e), xlsm_file))
print("File may not be an Excel xlsm macro file.")
exit()

Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self):
"""

super(App, self).__init__()
super().__init__()

self.part_names = []
self.heading_pairs = []
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, options=None):
"""

super(Chart, self).__init__()
super().__init__()

self.subtype = None
self.sheet_type = 0x0200
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, options=None):
Constructor.
"""
super(ChartArea, self).__init__()
super().__init__()

if options is None:
options = {}
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, options=None):
Constructor.
"""
super(ChartBar, self).__init__()
super().__init__()

if options is None:
options = {}
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, options=None):
Constructor.
"""
super(ChartColumn, self).__init__()
super().__init__()

if options is None:
options = {}
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart_doughnut.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, options=None):
Constructor.
"""
super(ChartDoughnut, self).__init__()
super().__init__()

self.vary_data_color = 1
self.rotation = 0
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, options=None):
Constructor.
"""
super(ChartLine, self).__init__()
super().__init__()

if options is None:
options = {}
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart_pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, options=None):
Constructor.
"""
super(ChartPie, self).__init__()
super().__init__()

self.vary_data_color = 1
self.rotation = 0
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart_radar.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, options=None):
Constructor.
"""
super(ChartRadar, self).__init__()
super().__init__()

if options is None:
options = {}
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, options=None):
Constructor.
"""
super(ChartScatter, self).__init__()
super().__init__()

if options is None:
options = {}
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/chart_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, options=None):
Constructor.
"""
super(ChartStock, self).__init__()
super().__init__()

self.show_crosses = 0
self.hi_low_lines = {}
Expand Down
4 changes: 2 additions & 2 deletions xlsxwriter/chartsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self):
"""

super(Chartsheet, self).__init__()
super().__init__()

self.is_chartsheet = True
self.drawing = None
Expand Down Expand Up @@ -98,7 +98,7 @@ def protect(self, password='', options=None):
self.protection = True

# Call the parent method.
super(Chartsheet, self).protect(password, copy)
super().protect(password, copy)

###########################################################################
#
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self):
"""

super(Comments, self).__init__()
super().__init__()
self.author_ids = {}

###########################################################################
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/contenttypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self):
"""

super(ContentTypes, self).__init__()
super().__init__()

# Copy the defaults in case we need to change them.
self.defaults = copy.deepcopy(defaults)
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self):
"""

super(Core, self).__init__()
super().__init__()

self.properties = {}

Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self):
"""

super(Custom, self).__init__()
super().__init__()

self.properties = []
self.pid = 1
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self):
"""

super(Drawing, self).__init__()
super().__init__()

self.drawings = []
self.embedded = 0
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, properties=None, xf_indices=None, dxf_indices=None):
if properties is None:
properties = {}

super(Format, self).__init__()
super().__init__()

self.xf_format_indices = xf_indices
self.dxf_format_indices = dxf_indices
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self):
"""

super(Metadata, self).__init__()
super().__init__()

###########################################################################
#
Expand Down
4 changes: 2 additions & 2 deletions xlsxwriter/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .exceptions import EmptyChartSeries


class Packager(object):
class Packager:
"""
A class for writing the Excel XLSX Packager file.
Expand Down Expand Up @@ -85,7 +85,7 @@ def __init__(self):
"""

super(Packager, self).__init__()
super().__init__()

self.tmpdir = ''
self.in_memory = False
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self):
"""

super(Relationships, self).__init__()
super().__init__()

self.relationships = []
self.id = 1
Expand Down
4 changes: 2 additions & 2 deletions xlsxwriter/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from warnings import warn


class Shape(object):
class Shape:
"""
A class for to represent Excel XLSX shape objects.
Expand All @@ -27,7 +27,7 @@ def __init__(self, shape_type, name, options):
Constructor.
"""
super(Shape, self).__init__()
super().__init__()
self.name = name
self.shape_type = shape_type
self.connect = 0
Expand Down
4 changes: 2 additions & 2 deletions xlsxwriter/sharedstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self):
"""

super(SharedStrings, self).__init__()
super().__init__()

self.string_table = None

Expand Down Expand Up @@ -120,7 +120,7 @@ def _write_si(self, string):


# A metadata class to store Excel strings between worksheets.
class SharedStringTable(object):
class SharedStringTable:
"""
A class to track Excel shared strings between worksheets.
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self):
"""

super(Styles, self).__init__()
super().__init__()

self.xf_formats = []
self.palette = []
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self):
"""

super(Table, self).__init__()
super().__init__()

self.properties = {}

Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/test/comparison/test_optimize10.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_create_file(self):
"""Test example file converting Unicode text."""

# Open the input file with the correct encoding.
textfile = open(self.txt_filename, mode='r', encoding='utf-8')
textfile = open(self.txt_filename, encoding='utf-8')

# Create an new Excel file and convert the text data.
workbook = Workbook(self.got_filename, {'constant_memory': True, 'in_memory': False})
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/test/comparison/test_unicode_polish_utf8.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_create_file(self):
"""Test example file converting Unicode text."""

# Open the input file with the correct encoding.
textfile = open(self.txt_filename, mode='r', encoding='utf-8')
textfile = open(self.txt_filename, encoding='utf-8')

# Create an new Excel file and convert the text data.
workbook = Workbook(self.got_filename)
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/test/comparison/test_unicode_shift_jis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_create_file(self):
"""Test example file converting Unicode text."""

# Open the input file with the correct encoding.
textfile = open(self.txt_filename, mode='r', encoding='shift_jis')
textfile = open(self.txt_filename, encoding='shift_jis')

# Create an new Excel file and convert the text data.
workbook = Workbook(self.got_filename)
Expand Down
Loading

0 comments on commit d0ce0fa

Please sign in to comment.