Skip to content

Commit 764151a

Browse files
committed
pyupgrade
1 parent 779cf84 commit 764151a

File tree

8 files changed

+23
-34
lines changed

8 files changed

+23
-34
lines changed

docs/source/conf.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# BrotliCFFI documentation build configuration file, created by
43
# sphinx-quickstart on Sat Oct 3 16:51:16 2015.
@@ -50,9 +49,9 @@
5049
master_doc = 'index'
5150

5251
# General information about the project.
53-
project = u'brotlicffi'
54-
copyright = u'%d, Cory Benfield' % (datetime.date.today().year,)
55-
author = u'Cory Benfield'
52+
project = 'brotlicffi'
53+
copyright = f'{datetime.date.today():%Y}, Cory Benfield'
54+
author = 'Cory Benfield'
5655

5756
# The version info for the project you're documenting, acts as replacement for
5857
# |version| and |release|, also used in various other places throughout the
@@ -226,8 +225,8 @@
226225
# (source start file, target name, title,
227226
# author, documentclass [howto, manual, or own class]).
228227
latex_documents = [
229-
(master_doc, 'BrotliCFFI.tex', u'BrotliCFFI Documentation',
230-
u'Cory Benfield', 'manual'),
228+
(master_doc, 'BrotliCFFI.tex', 'BrotliCFFI Documentation',
229+
'Cory Benfield', 'manual'),
231230
]
232231

233232
# The name of an image file (relative to this directory) to place at the top of
@@ -256,7 +255,7 @@
256255
# One entry per manual page. List of tuples
257256
# (source start file, name, description, authors, manual section).
258257
man_pages = [
259-
(master_doc, 'BrotliCFFI', u'BrotliCFFI Documentation',
258+
(master_doc, 'BrotliCFFI', 'BrotliCFFI Documentation',
260259
[author], 1)
261260
]
262261

@@ -270,7 +269,7 @@
270269
# (source start file, target name, title, author,
271270
# dir menu entry, description, category)
272271
texinfo_documents = [
273-
(master_doc, 'BrotliCFFI', u'BrotliCFFI Documentation',
272+
(master_doc, 'BrotliCFFI', 'BrotliCFFI Documentation',
274273
author, 'BrotliCFFI', 'One line description of project.',
275274
'Miscellaneous'),
276275
]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def run(self):
7979
if not bool(sysconfig.get_config_var("Py_GIL_DISABLED")):
8080
class BDistWheel(wheel.bdist_wheel.bdist_wheel):
8181
def finalize_options(self):
82-
self.py_limited_api = "cp3{}".format(sys.version_info[1])
82+
self.py_limited_api = f"cp3{sys.version_info[1]}"
8383
wheel.bdist_wheel.bdist_wheel.finalize_options(self)
8484
cmdclass['bdist_wheel'] = BDistWheel
8585

src/brotlicffi/_api.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import math
32
import enum
43
import threading
@@ -153,25 +152,23 @@ def _validate_mode(val):
153152
try:
154153
val = BrotliEncoderMode(val)
155154
except ValueError:
156-
raise error("%s is not a valid encoder mode" % val)
155+
raise error(f"{val} is not a valid encoder mode")
157156

158157

159158
def _validate_quality(val):
160159
"""
161160
Validate that the quality setting is valid.
162161
"""
163162
if not (0 <= val <= 11):
164-
raise error(
165-
"%d is not a valid quality, must be between 0 and 11" % val
166-
)
163+
raise error(f"{val} is not a valid quality, must be between 0 and 11")
167164

168165

169166
def _validate_lgwin(val):
170167
"""
171168
Validate that the lgwin setting is valid.
172169
"""
173170
if not (10 <= val <= 24):
174-
raise error("%d is not a valid lgwin, must be between 10 and 24" % val)
171+
raise error(f"{val} is not a valid lgwin, must be between 10 and 24")
175172

176173

177174
def _validate_lgblock(val):
@@ -180,8 +177,8 @@ def _validate_lgblock(val):
180177
"""
181178
if (val != 0) and not (16 <= val <= 24):
182179
raise error(
183-
"%d is not a valid lgblock, must be either 0 or between 16 and 24"
184-
% val
180+
f"{val} is not a valid lgblock, must be either 0 or between 16 "
181+
"and 24"
185182
)
186183

187184

@@ -208,12 +205,10 @@ def _set_parameter(encoder, parameter, parameter_name, val):
208205
# function returns a value we can live in hope that the brotli folks will
209206
# enforce their own constraints.
210207
if rc != lib.BROTLI_TRUE: # pragma: no cover
211-
raise error(
212-
"Error setting parameter %s: %d" % (parameter_name, val)
213-
)
208+
raise error(f"Error setting parameter {parameter_name}: {val}")
214209

215210

216-
class Compressor(object):
211+
class Compressor:
217212
"""
218213
An object that allows for streaming compression of data using the Brotli
219214
compression algorithm.
@@ -334,8 +329,8 @@ def flush(self):
334329
try:
335330
chunks = [self._compress(b'', lib.BROTLI_OPERATION_FLUSH)]
336331

337-
while ((lib.BrotliEncoderHasMoreOutput(self._encoder) ==
338-
lib.BROTLI_TRUE)):
332+
while (lib.BrotliEncoderHasMoreOutput(self._encoder) ==
333+
lib.BROTLI_TRUE):
339334
chunks.append(self._compress(b'', lib.BROTLI_OPERATION_FLUSH))
340335
finally:
341336
self.lock.release()
@@ -352,15 +347,15 @@ def finish(self):
352347
"Concurrently sharing Compressor objects is not allowed")
353348
try:
354349
chunks = []
355-
while ((lib.BrotliEncoderIsFinished(self._encoder) ==
356-
lib.BROTLI_FALSE)):
350+
while (lib.BrotliEncoderIsFinished(self._encoder) ==
351+
lib.BROTLI_FALSE):
357352
chunks.append(self._compress(b'', lib.BROTLI_OPERATION_FINISH))
358353
finally:
359354
self.lock.release()
360355
return b''.join(chunks)
361356

362357

363-
class Decompressor(object):
358+
class Decompressor:
364359
"""
365360
An object that allows for streaming decompression of Brotli-compressed
366361
data.
@@ -595,8 +590,8 @@ def can_accept_more_data(self):
595590
ret = True
596591
if len(self._unconsumed_data) > 0:
597592
ret = False
598-
if ((lib.BrotliDecoderHasMoreOutput(self._decoder) ==
599-
lib.BROTLI_TRUE)):
593+
if (lib.BrotliDecoderHasMoreOutput(self._decoder) ==
594+
lib.BROTLI_TRUE):
600595
ret = False
601596
finally:
602597
self.lock.release()

src/brotlicffi/_build.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import os
32
import sys
43

test/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import os
32
import os.path
43

test/test_compatibility.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
test_compatibility
43
~~~~~~~~~~~~~~~~~~
@@ -36,7 +35,7 @@ def test_brotli_version():
3635
)
3736
)
3837
assert brotlicffi.__version__.startswith(
39-
"%s.%s.%s." % (
38+
"{}.{}.{}.".format(
4039
brotli_versions["MAJOR"],
4140
brotli_versions["MINOR"],
4241
brotli_versions["PATCH"]

test/test_simple_compression.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
test_simple_compression
43
~~~~~~~~~~~~~~~~~~~~~~~~~

test/test_simple_decompression.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
test_simple_decompression
43
~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)