From 31f75fefc8547676585feb5fbd654978523caac6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:19:25 +0200 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#932) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.3 → v0.4.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.3...v0.4.7) - [github.com/tox-dev/pyproject-fmt: 1.8.0 → 2.1.3](https://github.com/tox-dev/pyproject-fmt/compare/1.8.0...2.1.3) - [github.com/abravalheri/validate-pyproject: v0.16 → v0.18](https://github.com/abravalheri/validate-pyproject/compare/v0.16...v0.18) - https://github.com/codespell-project/codespell/: v2.2.6 → v2.3.0 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update pytest.yml * Update pytest.yml * cleanup and move to .ruff.toml * pyproject.toml --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Çağtay Fabry --- .flake8 | 20 -- .github/workflows/pytest.yml | 12 +- .pre-commit-config.yaml | 8 +- .ruff.toml | 81 +++++++++ doc/json_mime_render_plugin/pyproject.toml | 11 +- doc/src/tutorials/timeseries_01.ipynb | 2 +- ...mations_02_coordinate_system_manager.ipynb | 2 +- pyproject.toml | 171 ++++++------------ weldx/asdf/file.py | 2 +- weldx/core/time_series.py | 2 +- 10 files changed, 161 insertions(+), 150 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/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 3b0232bf1..5bf3dc0b2 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -39,12 +39,12 @@ jobs: with: fetch-depth: '0' # Fetch all history for all tags and branches - - uses: CagtayFabry/pydeps2env@main + - uses: CagtayFabry/pydeps2env@v1.1.0 with: - file: 'pyproject.toml' + files: 'pyproject.toml' channels: 'conda-forge defaults' extras: 'test vis media' - setup_requires: 'include' + build_system: 'include' - name: Setup Conda Environment uses: mamba-org/setup-micromamba@v1.9.0 @@ -139,12 +139,12 @@ jobs: with: fetch-depth: '0' # Fetch all history for all tags and branches - - uses: CagtayFabry/pydeps2env@main + - uses: CagtayFabry/pydeps2env@v1.1.0 with: - file: 'pyproject.toml' + files: 'pyproject.toml' channels: 'conda-forge defaults' extras: 'test vis media' - setup_requires: 'include' + build_system: 'include' - name: Setup Conda Environment uses: mamba-org/setup-micromamba@v1.9.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f0e983d9..596b0a343 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: - mdformat-config # ----- Python formatting ----- - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.3 + rev: v0.4.7 hooks: # Run ruff linter. - id: ruff @@ -39,11 +39,11 @@ repos: # Run ruff formatter. - id: ruff-format - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.8.0 + rev: 2.1.3 hooks: - id: pyproject-fmt - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.16 + rev: v0.18 hooks: - id: validate-pyproject # ----- Jupyter Notebooks ----- @@ -63,7 +63,7 @@ repos: - --remove-kernel-metadata # ----- spellchecking ----- - repo: https://github.com/codespell-project/codespell/ - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell exclude: doc/src/legal-notice.md 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/json_mime_render_plugin/pyproject.toml b/doc/json_mime_render_plugin/pyproject.toml index 5875593b7..788035bed 100644 --- a/doc/json_mime_render_plugin/pyproject.toml +++ b/doc/json_mime_render_plugin/pyproject.toml @@ -1,5 +1,12 @@ [project] name = "myst-nb-json-renderer" version = "1" -[project.entry-points."myst_nb.mime_renderers"] -json_mime = "myst_nb_json_render_plugin:MimeRenderPlugin" +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +entry-points."myst_nb.mime_renderers".json_mime = "myst_nb_json_render_plugin:MimeRenderPlugin" 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/pyproject.toml b/pyproject.toml index 3c7557100..d11db8472 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,24 +1,31 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "setuptools>=64", + "setuptools-scm[toml]>=6.2", + "wheel", +] + [project] name = "weldx" description = "Python API for the WelDX file format and standard" readme = "README.md" keywords = [ - "bam", # TODO: add more keywords here! think of them as in a journal article. + "bam", # TODO: add more keywords here! think of them as in a journal article. "welding", "weldx", ] -license = {file = "LICENSE", name="BSD License"} +license = { file = "LICENSE", name = "BSD License" } authors = [ - {name="Çağtay Fabry", email="cagtay.fabry@bam.de"}, - {name="Volker Hirthammer", email="volker.hirthammer@bam.de"}, - {name="Martin K. Scherer", email="martin.scherer@bam.de"}, + { name = "Çağtay Fabry", email = "cagtay.fabry@bam.de" }, + { name = "Volker Hirthammer", email = "volker.hirthammer@bam.de" }, + { name = "Martin K. Scherer", email = "martin.scherer@bam.de" }, ] requires-python = ">=3.9" classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Education", "Intended Audience :: Science/Research", - "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", @@ -28,7 +35,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Topic :: Scientific/Engineering :: Physics", # TODO: add more topics here! + "Topic :: Scientific/Engineering :: Physics", # TODO: add more topics here! ] dynamic = [ # see: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#dynamic-metadata @@ -40,7 +47,7 @@ dependencies = [ "boltons", "bottleneck>=1.3.3", "fs", - "IPython", + "ipython", "meshio", "networkx>=2.8.2", "numpy>=1.20", @@ -52,114 +59,41 @@ dependencies = [ "sympy>=1.6", "xarray>=2022.9", ] -[project.optional-dependencies] -media = [ +optional-dependencies.media = [ "av", "dask-image", "pims", - "tifffile", # required by dask-image, but not listed in their requirements + "tifffile", # required by dask-image, but not listed in their requirements ] -test = [ +optional-dependencies.test = [ "nbval", "pytest>=6", "pytest-cov", "pytest-xdist", ] -vis = [ - "weldx_widgets>=0.2", -] -[project.urls] -bug_tracker = "https://github.com/BAMweldx/weldx/issues" -changelog = "https://github.com/BAMweldx/weldx/blob/master/CHANGELOG.md" -documentation = "https://weldx.readthedocs.io" -repository = "https://github.com/BAMweldx/weldx" -[project.scripts] -welding_schema = "weldx.asdf.cli.welding_schema:main" -[project.entry-points."asdf.extensions"] -weldx = "weldx.asdf.extension:get_extensions" -[project.entry-points."asdf.resource_mappings"] -weldx_schemas = "weldx.asdf.extension:get_resource_mappings" - -[build-system] -build-backend = "setuptools.build_meta" -requires = [ - "setuptools>=64", - "setuptools_scm[toml]>=6.2", - "wheel", +optional-dependencies.vis = [ + "weldx-widgets>=0.2", ] +urls.bug_tracker = "https://github.com/BAMweldx/weldx/issues" +urls.changelog = "https://github.com/BAMweldx/weldx/blob/master/CHANGELOG.md" +urls.documentation = "https://weldx.readthedocs.io" +urls.repository = "https://github.com/BAMweldx/weldx" +scripts.welding_schema = "weldx.asdf.cli.welding_schema:main" +entry-points."asdf.extensions".weldx = "weldx.asdf.extension:get_extensions" +entry-points."asdf.resource_mappings".weldx_schemas = "weldx.asdf.extension:get_resource_mappings" [tool.setuptools.packages.find] -where = ["."] +where = [ + ".", +] [tool.setuptools_scm] write_to = "weldx/_version.py" write_to_template = '__version__ = "{version}"' -[tool.ruff] -target-version = "py39" # designated Python version -line-length = 88 -exclude = [ - "__init__.py", - "doc/src/conf.py", -] - -[tool.ruff.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. -] - -# Allow pydocstyle violations in certain areas. -per-file-ignores."**/{tests,tags,asdf,devtools}/**" = ["D"] -per-file-ignores."conftest.py" = ["D"] -per-file-ignores."doc/src/tutorials/*" = ["D"] -per-file-ignores."doc/src/conf.py" = ["E501", # ignore long lines. - "RUF100", # do no check if 'noqa' is needed (circular import workaround) -] -# Allow prints in certain areas. -per-file-ignores."**/{cli,tests,tutorials,devtools}/**/*{.py,ipynb}" = ["T2"] - -external = ["B950"] - -[tool.ruff.lint.pydocstyle] -convention = "numpy" - -[tool.ruff.lint.mccabe] -max-complexity = 15 # max branches inside a function. - -[tool.ruff.lint.isort] -known-first-party = ["weldx"] -required-imports = ["from __future__ import annotations"] - -[tool.ruff.lint.flake8-import-conventions] -extend-aliases = {xarray = "xr"} - [tool.nbqa.addopts] ruff = [ - "--extend-ignore=B018" + "--extend-ignore=B018", ] [tool.pytest.ini_options] @@ -168,37 +102,39 @@ addopts = "--tb=short --color=yes -rsw --cov=weldx --cov-report=term-missing:ski testpaths = "weldx" # custom test markers, see https://docs.pytest.org/en/latest/example/markers.html#mark-examples markers = "slow: marks tests as slow to run (skipped by default, enable with --runslow option)" -asdf_schema_root = "weldx/schemas/weldx.bam.de/weldx" # TODO: couldn't we just use the entry points to resolve this? +asdf_schema_root = "weldx/schemas/weldx.bam.de/weldx" # TODO: couldn't we just use the entry points to resolve this? #asdf_schema_tests_enabled = true #asdf_schema_skip_tests = # weldx.bam.de/weldx/datamodels/single_pass_weld-1.0.0.schema.yaml norecursedirs = [ - "doc", - ".ipynb_checkpoints", + "doc", + ".ipynb_checkpoints", ] filterwarnings = [ - "ignore::DeprecationWarning:traittypes.*:", - "ignore:Passing method to :FutureWarning:xarray.*:", - "error::pint.UnitStrippedWarning", - #"error::FutureWarning", # todo: we want to enable this, as it notifies us about upcoming failures due to upstream changes. + "ignore::DeprecationWarning:traittypes.*:", + "ignore:Passing method to :FutureWarning:xarray.*:", + "error::pint.UnitStrippedWarning", + #"error::FutureWarning", # todo: we want to enable this, as it notifies us about upcoming failures due to upstream changes. ] [tool.coverage.run] -source = ["weldx"] +source = [ + "weldx", +] [tool.coverage.report] omit = [ - "weldx/_version.py", - "weldx/tests/*", + "weldx/_version.py", + "weldx/tests/*", ] exclude_lines = [ -# Have to re-enable the standard pragma - "pragma: no cover", + # Have to re-enable the standard pragma + "pragma: no cover", -# ignore class __repr__-like functions: - "def __repr__", - "def __str__", - "def _ipython_display_", + # ignore class __repr__-like functions: + "def __repr__", + "def __str__", + "def _ipython_display_", ] [tool.mypy] @@ -215,13 +151,20 @@ sqlite_cache = true # MyPy per-module options: [[tool.mypy.overrides]] -module = ["weldx.asdf.*", "weldx.tags.*", "weldx.tests.*", "weldx.welding.groove.*", "weldx.geometry.*" ] +module = [ + "weldx.asdf.*", + "weldx.tags.*", + "weldx.tests.*", + "weldx.welding.groove.*", + "weldx.geometry.*", +] ignore_errors = true # this is a workaround for an xarray related mypy bug # see https://github.com/python/mypy/pull/9495 # and https://github.com/space-physics/msise00/commit/8b59a9383dd6fcc54b7dac74eb95a350308d7b62 # TODO: is this still mandatory? + [[tool.mypy.overrides]] module = "xarray" follow_imports = "skip" 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", diff --git a/weldx/core/time_series.py b/weldx/core/time_series.py index 64abdec3d..05bca65fa 100644 --- a/weldx/core/time_series.py +++ b/weldx/core/time_series.py @@ -2,13 +2,13 @@ from __future__ import annotations +from _warnings import warn from typing import TYPE_CHECKING, Any import numpy as np import pandas as pd import pint import xarray as xr -from _warnings import warn from weldx import Q_ from weldx import util as ut