From d347f309a86320d392fdf589148e643bf0e91634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Ftay=20Fabry?= Date: Tue, 4 Jun 2024 11:50:40 +0200 Subject: [PATCH] cleanup and move to .ruff.toml --- .flake8 | 20 ----- .ruff.toml | 81 +++++++++++++++++++ doc/src/tutorials/timeseries_01.ipynb | 2 +- ...mations_02_coordinate_system_manager.ipynb | 2 +- weldx/asdf/file.py | 2 +- 5 files changed, 84 insertions(+), 23 deletions(-) delete mode 100644 .flake8 create mode 100644 .ruff.toml diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 1f44fa6a5..000000000 --- a/.flake8 +++ /dev/null @@ -1,20 +0,0 @@ -# flake8 maintainer does not like pyproject.toml: -# https://github.com/PyCQA/flake8/issues/234#issuecomment-812800722 - -[flake8] -# References: -# https://flake8.readthedocs.io/en/latest/user/configuration.html -# https://flake8.readthedocs.io/en/latest/user/error-codes.html - -# Note: there cannot be spaces after comma's here -ignore = - W503,W504 - E203 - C408 - -max-line-length = 88 -select = C,E,F,W,B,B950 # black formatting options -exclude = - __init__.py - doc/src/conf.py -no-accept-encodings = True diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 000000000..f6d0285ea --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,81 @@ +# Exclude a variety of commonly ignored directories. +extend-exclude = [ + "__init__.py", + "doc/src/conf.py", +] + +# Same as Black. +line-length = 88 +indent-width = 4 + +# Assume Python 3.9 +target-version = "py39" + + +[lint] +# TODO: should be the following list, but Ruff does not yet impl all of them. +# W503,W504 +# E203 +# C408 +ignore = [ + "C408", + #"E203", + "E402", + #"W503", + #"W504", + "D203", + "D211", + "D213", + "UP006", + "UP007", # see ruff GH#4427 +] +select = [ + "B", # flake8-bugbear + "C", # flake8-comprehensions + #"D", # note: all relevant D's will be set by setting pydocstyle.convention=numpy! + "E", # pycodestyles + "F", # pyflakes + "W", # pycodestyle warnings + "UP", # pyupgrade + "T2", # flake8-print + "I001", # isort + "ICN", # import conventions, e.g. import numpy as np + #"B950", # not yet implemented by Ruff. + "RUF100", # ensure 'noqa' declarations are still valid. +] + +[lint.extend-per-file-ignores] +# Allow pydocstyle violations in certain areas. +"**/{tests,tags,asdf,devtools}/**" = [ + "D", +] +"conftest.py" = [ + "D", +] +"doc/src/tutorials/*" = [ + "D", +] +"doc/src/conf.py" = [ + "E501", # ignore long lines. + "RUF100", # do no check if 'noqa' is needed (circular import workaround) +] +"**/{cli,tests,tutorials,devtools}/**/*{.py,ipynb}" = [ + "T2", +] # Allow prints in certain areas. + +[lint.pydocstyle] +convention = "numpy" + +[lint.mccabe] +max-complexity = 15 # max branches inside a function. + +[lint.isort] +known-first-party = [ + "weldx", +] +required-imports = [ + "from __future__ import annotations", +] + +[flake8-import-conventions] +extend-aliases = { xarray = "xr" } diff --git a/doc/src/tutorials/timeseries_01.ipynb b/doc/src/tutorials/timeseries_01.ipynb index 7e0464c93..e94801a42 100644 --- a/doc/src/tutorials/timeseries_01.ipynb +++ b/doc/src/tutorials/timeseries_01.ipynb @@ -283,7 +283,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can also use `Quantites` with the appropriate dimension as Inputs for our interpolation:" + "We can also use `Quantities` with the appropriate dimension as Inputs for our interpolation:" ] }, { diff --git a/doc/src/tutorials/transformations_02_coordinate_system_manager.ipynb b/doc/src/tutorials/transformations_02_coordinate_system_manager.ipynb index 246c0145c..78d3ee4c5 100644 --- a/doc/src/tutorials/transformations_02_coordinate_system_manager.ipynb +++ b/doc/src/tutorials/transformations_02_coordinate_system_manager.ipynb @@ -529,7 +529,7 @@ "metadata": {}, "source": [ "The `SpatialData` class we used above is mostly a container class for 3d data.\n", - "Additionally to pure point data, it can also store connectivety data in form of triangles.\n", + "Additionally to pure point data, it can also store connectivity data in form of triangles.\n", "Consult the [class documentation](https://weldx.readthedocs.io/en/latest/_autosummary/weldx.SpatialData.html#weldx.SpatialData) for further information.\n", "Now we add the data to the CSM:" ] diff --git a/weldx/asdf/file.py b/weldx/asdf/file.py index c24dfadfb..f75ec0583 100644 --- a/weldx/asdf/file.py +++ b/weldx/asdf/file.py @@ -443,7 +443,7 @@ def software_history_entry(self): Examples -------- - Let us define a custom softare entry and use it during file creation. + Let us define a custom software entry and use it during file creation. >>> import weldx >>> software = dict(name="MyFancyPackage", author="Me",