From 1986a950633a99396c7d42b116e466a09c77682a Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Sat, 15 Oct 2022 17:12:10 +0800 Subject: [PATCH] Fix typos and add codespell to nox --- README.rst | 4 ++-- doc/cli/image.rst | 4 ++-- doc/contributing.rst | 4 +++- noxfile.py | 15 ++++++++++++++- setup.py | 3 ++- test/test_model_options.py | 2 +- yoga/image/encoders/png.py | 4 ++-- yoga/image/encoders/webp.py | 6 +++--- yoga/model/__init__.py | 4 ++-- yoga/model/helpers.py | 2 +- 10 files changed, 32 insertions(+), 16 deletions(-) diff --git a/README.rst b/README.rst index eb24dfa..8fbfbaa 100644 --- a/README.rst +++ b/README.rst @@ -112,7 +112,7 @@ Changelog * WEBP (lossy and lossless) images supported as output format * PNG default optimization preset changed to a 10× faster preset (old preset - stil available with ``--png-slow-optimization`` flag) + still available with ``--png-slow-optimization`` flag) * New model flag ``--no-fix-infacing-normals`` to disable Assimp's "fix infacing normals" postprocess (#32, #33) * Show CLI usage when no parameter given @@ -136,7 +136,7 @@ Changelog * **0.10.1:** - * Fixes an issue that occures when output file does not already exist + * Fixes an issue that occurs when output file does not already exist * **0.10.0:** diff --git a/doc/cli/image.rst b/doc/cli/image.rst index 175b8b9..0ef684e 100644 --- a/doc/cli/image.rst +++ b/doc/cli/image.rst @@ -78,8 +78,8 @@ Resize Output Image YOGA allows you to resize images with the ``--resize`` option:: - yoga image --resize=512 input.png ouput.png - yoga image --resize=512x512 input.png ouput.png + yoga image --resize=512 input.png output.png + yoga image --resize=512x512 input.png output.png .. NOTE:: diff --git a/doc/contributing.rst b/doc/contributing.rst index 7f5e255..e46f038 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -108,9 +108,10 @@ Libraries: Development tools: -* Black_: Code formater +* Black_: Code formatter * Flake8_: Linter * Pytest_: Unit test +* Codespell_: Code spell Documentation: @@ -258,5 +259,6 @@ Then you can run the following command:: .. _Flake8: https://flake8.pycqa.org/en/latest/ .. _Black: https://black.readthedocs.io/en/stable/ .. _pytest: https://docs.pytest.org/ +.. _Codespell: https://github.com/codespell-project/codespell .. _Sphinx: https://www.sphinx-doc.org/en/master/ diff --git a/noxfile.py b/noxfile.py index 1592cc0..daf2f19 100644 --- a/noxfile.py +++ b/noxfile.py @@ -11,7 +11,7 @@ PYTHON_FILES = [ @nox.session(reuse_venv=True) def lint(session): - session.install("flake8", "black") + session.install("flake8", "black", "codespell") session.run("flake8", *PYTHON_FILES) session.run( "black", @@ -21,6 +21,19 @@ def lint(session): "--color", *PYTHON_FILES, ) + session.run( + "codespell", + "-L", + "ans,alph", + "doc/", + "scripts/", + "test/", + "winbuild/", + "yoga/", + "noxfile.py", + "README.rst", + "setup.py", + ) @nox.session(reuse_venv=True) diff --git a/setup.py b/setup.py index 5a988f4..7f53922 100644 --- a/setup.py +++ b/setup.py @@ -98,8 +98,9 @@ setup( "flake8", "black", "pytest", - "Sphinx", + "sphinx", "sphinx-rtd-theme", + "codespell", ] }, entry_points={ diff --git a/test/test_model_options.py b/test/test_model_options.py index 968867a..29de9c3 100644 --- a/test/test_model_options.py +++ b/test/test_model_options.py @@ -46,7 +46,7 @@ class Test_normalize_options(object): with pytest.raises(IOError): opt = options.normalize_options( - {"fallback_texture": "non-existant.jpg"} + {"fallback_texture": "non-existent.jpg"} ) def test_no_graph_optimization(self): diff --git a/yoga/image/encoders/png.py b/yoga/image/encoders/png.py index ade71fb..7678b3c 100644 --- a/yoga/image/encoders/png.py +++ b/yoga/image/encoders/png.py @@ -35,7 +35,7 @@ def python_int_to_big_endian_uint32_bytes(number): def get_png_structure(data): if not is_png(data): - raise ValueError("Unvalid PNG: Not a PNG file") + raise ValueError("Invalid PNG: Not a PNG file") result = { "size": len(data), @@ -86,7 +86,7 @@ def get_IHDR_info(data): def assemble_png_from_chunks(chunks): """Assemble a PNG file from a list of chunks - :param list chunks: The list of chunks (see bellow). + :param list chunks: The list of chunks (see below). Example list of chunk:: diff --git a/yoga/image/encoders/webp.py b/yoga/image/encoders/webp.py index 2626240..0801bab 100644 --- a/yoga/image/encoders/webp.py +++ b/yoga/image/encoders/webp.py @@ -8,7 +8,7 @@ def little_endian_unint32_bytes_to_python_int(bytes_): def get_riff_structure(data): if data[0:4] != b"RIFF": - raise ValueError("Unvalid RIFF: Not a RIFF file") + raise ValueError("Invalid RIFF: Not a RIFF file") result = { "formtype": data[8:12].decode(), @@ -17,7 +17,7 @@ def get_riff_structure(data): } if result["size"] + 8 != len(data): - raise ValueError("Unvalid RIFF: Truncated data") + raise ValueError("Invalid RIFF: Truncated data") offset = 12 # RIFF header length @@ -46,7 +46,7 @@ def get_vp8x_info(data): # fmt: on if len(data) != 10: - ValueError("Invaild VP8X data") + ValueError("Invalid VP8X data") return { "has_icc": bool(data[0] & VP8X_FLAG_ICC), diff --git a/yoga/model/__init__.py b/yoga/model/__init__.py index a160814..339ca18 100644 --- a/yoga/model/__init__.py +++ b/yoga/model/__init__.py @@ -198,7 +198,7 @@ def optimize( :param str,file-like input_file: The input model file. :param str,file-like output_file: The output model file. :param dict options: Optimization options (see above). - :param dict textures: A dictionnary that maps textures path to bytes. When + :param dict textures: A dictionary that maps textures path to bytes. When not ``None``, there will be no file system reads in order to find referenced textures. YOGA will look into that dictionary instead. @@ -246,7 +246,7 @@ def optimize( ) # Embed images - # @note We save the bytes to a dictionnary so that the garbage collector + # @note We save the bytes to a dictionary so that the garbage collector # does not occur before exporting the scene a bit later images_bytes = {} model_embed_images( diff --git a/yoga/model/helpers.py b/yoga/model/helpers.py index 1d38f07..efce99f 100644 --- a/yoga/model/helpers.py +++ b/yoga/model/helpers.py @@ -176,6 +176,6 @@ def model_embed_images( optimized_textures[valid_image_path] = image image = image.next - # @note Save the bytes to a dictionnary so that the garbage collector + # @note Save the bytes to a dictionary so that the garbage collector # does not occur before exporting the scene a bit later images_bytes[valid_image_path] = image_bytes_c