diff --git a/docs/source/conf.py b/docs/source/conf.py index 16761d0..4d0148d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # BrotliCFFI documentation build configuration file, created by # sphinx-quickstart on Sat Oct 3 16:51:16 2015. @@ -50,9 +49,9 @@ master_doc = 'index' # General information about the project. -project = u'brotlicffi' -copyright = u'%d, Cory Benfield' % (datetime.date.today().year,) -author = u'Cory Benfield' +project = 'brotlicffi' +copyright = f'{datetime.date.today():%Y}, Cory Benfield' +author = 'Cory Benfield' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -226,8 +225,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'BrotliCFFI.tex', u'BrotliCFFI Documentation', - u'Cory Benfield', 'manual'), + (master_doc, 'BrotliCFFI.tex', 'BrotliCFFI Documentation', + 'Cory Benfield', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -256,7 +255,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'BrotliCFFI', u'BrotliCFFI Documentation', + (master_doc, 'BrotliCFFI', 'BrotliCFFI Documentation', [author], 1) ] @@ -270,7 +269,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'BrotliCFFI', u'BrotliCFFI Documentation', + (master_doc, 'BrotliCFFI', 'BrotliCFFI Documentation', author, 'BrotliCFFI', 'One line description of project.', 'Miscellaneous'), ] diff --git a/setup.py b/setup.py index 73b2ef8..e7e24f3 100644 --- a/setup.py +++ b/setup.py @@ -79,7 +79,7 @@ def run(self): if not bool(sysconfig.get_config_var("Py_GIL_DISABLED")): class BDistWheel(wheel.bdist_wheel.bdist_wheel): def finalize_options(self): - self.py_limited_api = "cp3{}".format(sys.version_info[1]) + self.py_limited_api = f"cp3{sys.version_info[1]}" wheel.bdist_wheel.bdist_wheel.finalize_options(self) cmdclass['bdist_wheel'] = BDistWheel diff --git a/src/brotlicffi/_api.py b/src/brotlicffi/_api.py index e6601f4..df9a640 100644 --- a/src/brotlicffi/_api.py +++ b/src/brotlicffi/_api.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import math import enum import threading @@ -153,7 +152,7 @@ def _validate_mode(val): try: val = BrotliEncoderMode(val) except ValueError: - raise error("%s is not a valid encoder mode" % val) + raise error(f"{val} is not a valid encoder mode") def _validate_quality(val): @@ -161,9 +160,7 @@ def _validate_quality(val): Validate that the quality setting is valid. """ if not (0 <= val <= 11): - raise error( - "%d is not a valid quality, must be between 0 and 11" % val - ) + raise error(f"{val} is not a valid quality, must be between 0 and 11") def _validate_lgwin(val): @@ -171,7 +168,7 @@ def _validate_lgwin(val): Validate that the lgwin setting is valid. """ if not (10 <= val <= 24): - raise error("%d is not a valid lgwin, must be between 10 and 24" % val) + raise error(f"{val} is not a valid lgwin, must be between 10 and 24") def _validate_lgblock(val): @@ -180,8 +177,8 @@ def _validate_lgblock(val): """ if (val != 0) and not (16 <= val <= 24): raise error( - "%d is not a valid lgblock, must be either 0 or between 16 and 24" - % val + f"{val} is not a valid lgblock, must be either 0 or between 16 " + "and 24" ) @@ -208,12 +205,10 @@ def _set_parameter(encoder, parameter, parameter_name, val): # function returns a value we can live in hope that the brotli folks will # enforce their own constraints. if rc != lib.BROTLI_TRUE: # pragma: no cover - raise error( - "Error setting parameter %s: %d" % (parameter_name, val) - ) + raise error(f"Error setting parameter {parameter_name}: {val}") -class Compressor(object): +class Compressor: """ An object that allows for streaming compression of data using the Brotli compression algorithm. @@ -334,8 +329,8 @@ def flush(self): try: chunks = [self._compress(b'', lib.BROTLI_OPERATION_FLUSH)] - while ((lib.BrotliEncoderHasMoreOutput(self._encoder) == - lib.BROTLI_TRUE)): + while (lib.BrotliEncoderHasMoreOutput(self._encoder) == + lib.BROTLI_TRUE): chunks.append(self._compress(b'', lib.BROTLI_OPERATION_FLUSH)) finally: self.lock.release() @@ -352,15 +347,15 @@ def finish(self): "Concurrently sharing Compressor objects is not allowed") try: chunks = [] - while ((lib.BrotliEncoderIsFinished(self._encoder) == - lib.BROTLI_FALSE)): + while (lib.BrotliEncoderIsFinished(self._encoder) == + lib.BROTLI_FALSE): chunks.append(self._compress(b'', lib.BROTLI_OPERATION_FINISH)) finally: self.lock.release() return b''.join(chunks) -class Decompressor(object): +class Decompressor: """ An object that allows for streaming decompression of Brotli-compressed data. @@ -595,8 +590,8 @@ def can_accept_more_data(self): ret = True if len(self._unconsumed_data) > 0: ret = False - if ((lib.BrotliDecoderHasMoreOutput(self._decoder) == - lib.BROTLI_TRUE)): + if (lib.BrotliDecoderHasMoreOutput(self._decoder) == + lib.BROTLI_TRUE): ret = False finally: self.lock.release() diff --git a/src/brotlicffi/_build.py b/src/brotlicffi/_build.py index 115be2e..af2e09f 100644 --- a/src/brotlicffi/_build.py +++ b/src/brotlicffi/_build.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os import sys diff --git a/test/conftest.py b/test/conftest.py index e1de064..08c5cbf 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os import os.path diff --git a/test/test_compatibility.py b/test/test_compatibility.py index 8aeadab..7922ee4 100644 --- a/test/test_compatibility.py +++ b/test/test_compatibility.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ test_compatibility ~~~~~~~~~~~~~~~~~~ @@ -36,7 +35,7 @@ def test_brotli_version(): ) ) assert brotlicffi.__version__.startswith( - "%s.%s.%s." % ( + "{}.{}.{}.".format( brotli_versions["MAJOR"], brotli_versions["MINOR"], brotli_versions["PATCH"] diff --git a/test/test_simple_compression.py b/test/test_simple_compression.py index a480587..92f571a 100644 --- a/test/test_simple_compression.py +++ b/test/test_simple_compression.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ test_simple_compression ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/test/test_simple_decompression.py b/test/test_simple_decompression.py index 232a730..3d29ca4 100644 --- a/test/test_simple_decompression.py +++ b/test/test_simple_decompression.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ test_simple_decompression ~~~~~~~~~~~~~~~~~~~~~~~~~