Skip to content

Commit

Permalink
Project metadata to pyproject.toml + remove i18n (#107)
Browse files Browse the repository at this point in the history
* project metadata defined in project.toml
* remove i18n base class
* ruff
* black
* fix k3d test
* removed kisa submod
* fix b017, raise specific exception
* fix bugbear os.environ assignment
* fix bugbear exception chaining
* remove flake8 settings (moved to ruff)
* remove pydocstyle precommit (moved to ruff)
* removed unused abstract methods in import/export interface
* renamed FloatWithUnit -> WidgetFloatWithUnit
---------

Co-authored-by: Cagtay Fabry <43667554+CagtayFabry@users.noreply.github.com>
  • Loading branch information
marscher and CagtayFabry authored Dec 14, 2023
1 parent dfc415b commit 973c716
Show file tree
Hide file tree
Showing 31 changed files with 321 additions and 1,500 deletions.
29 changes: 10 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:
for more information, see https://pre-commit.ci
autofix_prs: false
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
autoupdate_schedule: monthly
skip: []
submodules: false
repos:
Expand All @@ -16,21 +16,12 @@ repos:
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-yaml
exclude: devtools/conda.recipe/meta.yaml # doesn't play nice with jinja
# - id: no-commit-to-branch # only makes sense for local pre-commit hooks
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
142 changes: 142 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,151 @@
[project]
name = "weldx_widgets"
dynamic = [ # see: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#dynamic-metadata
"version", # version gets derived from git by setuptools_scm.
]
authors = [
{name="Martin K. Scherer", email="martin.scherer@bam.de"},
{name="Cagtay Fabry", email="cagtay.fabry@bam.de"}
]
description="Python based widgets for the weldx core package"
readme = "README.md"
license = {file = "LICENSE", name="BSD License"}
keywords = [
"weldx",
"ipywidgets",
"widgets",
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering :: Physics",
]

# Dependencies
requires-python = ">=3.9"
dependencies = [
"weldx >=0.6",
"ipywidgets",
"k3d >=2.12",
"ipympl",
"bidict",
"ipyfilechooser",
"tqdm",
]
[project.optional-dependencies]
test = [
"pytest-cov",
"pytest-xdist"
]

[project.urls]
documentation = "https://weldx.readthedocs.io"
repository = "https://github.com/BAMweldx/weldx-widgets"
bug_tracker = "https://github.com/BAMweldx/weldx-widgets/issues"
changelog = "https://github.com/BAMweldx/weldx-widgets/blob/master/CHANGELOG.md"

[build-system]
requires = ["setuptools>=45",
"wheel",
"setuptools_scm[toml]>=6.0",
"babel",
]

# Tool configs
[tool.setuptools_scm]
write_to = "weldx_widgets/_version.py"
write_to_template = '__version__ = "{version}"'

[tool.setuptools.packages.find]
where = ["."]

[tool.pytest.ini_options]
addopts = "--tb=short --color=yes -rsw --doctest-modules --cov=weldx_widgets"
testpaths = "weldx_widgets/tests"
filterwarnings = [
"ignore::DeprecationWarning:traittypes.*:",
"ignore:Passing method to :FutureWarning:xarray.*:",
"error::pint.UnitStrippedWarning",
]

[tool.coverage.run]
source = ["weldx_widgets"]

[tool.coverage.report]
omit = [
"weldx_widgets/_version.py",
"weldx_widgets/tests/*",
]
exclude_lines = [
# Have to re-enable the standard pragma
"pragma: no cover",
]

[tool.ruff]
target-version = "py38" # designated Python version
exclude = [
"__init__.py",
"doc/src/conf.py",
]
# 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"
]
line-length = 88
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"]
pydocstyle = {convention = "numpy"}
pyupgrade = {keep-runtime-typing = true}

mccabe = {max-complexity = 15} # max branches inside a function.

[tool.ruff.isort]
known-first-party = ["weldx"]
required-imports = ["from __future__ import annotations"]

[tool.ruff.flake8-import-conventions]
extend-aliases = {xarray = "xr"}

[tool.nbqa.addopts]
ruff = [
"--extend-ignore=B018"
]
87 changes: 0 additions & 87 deletions setup.cfg

This file was deleted.

27 changes: 0 additions & 27 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions weldx_widgets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Weldx widgets."""
from .generic import WidgetSaveButton, WidgetTimeSeries
from .widget_factory import FloatWithUnit, WidgetLabeledTextInput
from .widget_factory import WidgetFloatWithUnit, WidgetLabeledTextInput
from .widget_gas import WidgetShieldingGas
from .widget_gmaw import WidgetGMAW
from .widget_groove_sel import WidgetGrooveSelection, WidgetGrooveSelectionTCPMovement
Expand All @@ -13,7 +13,7 @@
WidgetLabeledTextInput,
WidgetSaveButton,
WidgetGMAW,
FloatWithUnit, # TODO: rename
WidgetFloatWithUnit,
]
__all__ = map(str, (x.__name__ for x in __all__))

Expand Down
20 changes: 6 additions & 14 deletions weldx_widgets/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from ipywidgets import HTML, Button, HBox, Label

import weldx
from weldx_widgets.translation_utils import _i18n as _
from weldx_widgets.widget_base import WeldxImportExport, WidgetMyHBox, WidgetMyVBox
from weldx_widgets.widget_factory import (
WidgetLabeledTextInput,
Expand Down Expand Up @@ -59,14 +58,12 @@ def __init__(
filename=filename,
filter_pattern=filter_pattern,
select_default=select_default,
select_desc=_("Select"),
change_desc=_("Change"),
select_desc="Select",
change_desc="Change",
)
self.button = Button(description=_(desc), layout=button_layout)
self.button = Button(description=desc, layout=button_layout)

super(WidgetSaveButton, self).__init__(
children=(self.file_chooser, self.button)
)
super().__init__(children=(self.file_chooser, self.button))

def set_handler(self, handler: Callable):
"""Set action handler on save button click."""
Expand All @@ -91,11 +88,6 @@ def path(self):
class WidgetTimeSeries(WidgetMyVBox, WeldxImportExport):
"""Preliminary time series editing widget."""

@property
def schema(self) -> str:
"""Return schema to validate data against."""
return "time_series"

# TODO: handle math-expr
def __init__(
self, base_unit, time_unit="s", base_data="0", time_data="0", title=""
Expand All @@ -121,7 +113,7 @@ def __init__(
]
if title:
children.insert(0, Label(title))
super(WidgetTimeSeries, self).__init__(children=children)
super().__init__(children=children)

def to_tree(self) -> dict:
"""Get mapping of input fields."""
Expand Down Expand Up @@ -153,7 +145,7 @@ def download_button(
button_description: str,
html_instance: Optional[HTML] = None,
) -> HTML:
"""Load data from buffer into base64 payload embedded into a HTML button.
"""Load data from buffer into base64 payload embedded into an HTML button.
Parameters
----------
Expand Down
1 change: 0 additions & 1 deletion weldx_widgets/kisa/__init__.py

This file was deleted.

Loading

0 comments on commit 973c716

Please sign in to comment.