diff --git a/.github/workflows/test_and_release.yml b/.github/workflows/test_and_release.yml index ea71065..bb4b105 100644 --- a/.github/workflows/test_and_release.yml +++ b/.github/workflows/test_and_release.yml @@ -2,9 +2,9 @@ name: Test and Release on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: pre-commit: @@ -34,18 +34,9 @@ jobs: matrix: python-version: [3.9] config: - - { - name: "Linux", - os: ubuntu-latest - } - - { - name: "MacOSX", - os: macos-latest - } - - { - name: "Windows", - os: windows-latest - } + - { name: "Linux", os: ubuntu-latest } + - { name: "MacOSX", os: macos-latest } + - { name: "Windows", os: windows-latest } defaults: run: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1dfaa0c..63b3465 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,90 @@ +ci: + autoupdate_commit_msg: "chore: update pre-commit hooks" + autofix_commit_msg: "style: pre-commit fixes" + +exclude: ^.cruft.json|.copier-answers.yml$ + repos: - - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v6.0.0" hooks: - - id: codespell + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: name-tests-test + args: ["--pytest-test-first"] + - id: requirements-txt-fixer + - id: trailing-whitespace + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: "v1.10.0" + hooks: + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal + + - repo: https://github.com/rbubley/mirrors-prettier + rev: "v3.8.1" + hooks: + - id: prettier + types_or: [yaml, markdown, html, css, scss, javascript, json] + args: [--prose-wrap=always] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.13.0 + rev: "v0.15.0" hooks: - id: ruff + args: ["--fix", "--show-fixes"] - id: ruff-format + # - repo: https://github.com/pre-commit/mirrors-mypy + # rev: "v1.14.1" + # hooks: + # - id: mypy + # files: src|tests + # args: [] + # additional_dependencies: + # - pytest + + - repo: https://github.com/codespell-project/codespell + rev: "v2.4.1" + hooks: + - id: codespell + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: "v0.11.0.1" + hooks: + - id: shellcheck + + - repo: local + hooks: + - id: disallow-caps + name: Disallow improper capitalization + language: pygrep + entry: PyBind|Numpy|Cmake|CCache|Github|PyTest + exclude: .pre-commit-config.yaml + + - repo: https://github.com/abravalheri/validate-pyproject + rev: "v0.25" + hooks: + - id: validate-pyproject + additional_dependencies: ["validate-pyproject-schema-store[all]"] + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: "0.36.1" + hooks: + - id: check-dependabot + - id: check-github-workflows + - id: check-readthedocs + + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.24.0 + hooks: + - id: commitlint + stages: [commit-msg] + additional_dependencies: ["@commitlint/config-conventional"] diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..dd44972 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +*.md diff --git a/docs/definitions.md b/docs/definitions.md index 5eef420..115f94c 100644 --- a/docs/definitions.md +++ b/docs/definitions.md @@ -242,4 +242,4 @@ properties. So far, the supported layout values for a property are: - `vertical`, `l2`, `l3`, `l4`, `m3-half`. - The `l{number}` are for grouping `number` entries per line. -- Skipping layout is the same as setting it to `horizontal`. \ No newline at end of file +- Skipping layout is the same as setting it to `horizontal`. diff --git a/examples/00_AddressBook/definitions/lang_en.yaml b/examples/00_AddressBook/definitions/lang_en.yaml index bcf6158..b6aa43f 100644 --- a/examples/00_AddressBook/definitions/lang_en.yaml +++ b/examples/00_AddressBook/definitions/lang_en.yaml @@ -16,4 +16,4 @@ Person: ZipCode: _label: Zip Code Country: - _label: Country \ No newline at end of file + _label: Country diff --git a/examples/01_Widgets/definitions/model.yaml b/examples/01_Widgets/definitions/model.yaml index a93b26d..8d3b5d4 100644 --- a/examples/01_Widgets/definitions/model.yaml +++ b/examples/01_Widgets/definitions/model.yaml @@ -8,8 +8,8 @@ TextField: DualHorizontalString: _label: Dual Text Field for int8 _help: >- - Example of Text widget with numerical entry - With some multi line example... + Example of Text widget with numerical entry with some multi line + example... size: 2 type: int8 initial: @@ -213,7 +213,7 @@ Select: size: -1 initial: - A - - '1' + - "1" domains: - type: LabelList values: @@ -224,9 +224,9 @@ Select: value: B - header: Number cases - text: Case 1 - value: '1' + value: "1" - text: Case 2 - value: '2' + value: "2" SelectDynamicList: _label: Dynamic available @@ -259,14 +259,13 @@ Switch: BasicOnBool: _label: On Switch as Bool _help: >- - Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna - aliqua. Ut enim ad minim veniam, quis nostrud exercitation - ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit - esse cillum dolore eu fugiat nulla pariatur. Excepteur sint - occaecat cupidatat non proident, sunt in culpa qui officia - deserunt mollit anim id est laborum. + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim + veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea + commodo consequat. Duis aute irure dolor in reprehenderit in voluptate + velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat + cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id + est laborum. type: bool initial: true domains: @@ -285,16 +284,14 @@ TextArea: BigText1: _label: Programmable Filter - Request data _help: >- - This field allow you enter VTK code and describe the - filter processing core. - Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna - aliqua. Ut enim ad minim veniam, quis nostrud exercitation - ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit - esse cillum dolore eu fugiat nulla pariatur. Excepteur sint - occaecat cupidatat non proident, sunt in culpa qui officia - deserunt mollit anim id est laborum. + This field allow you enter VTK code and describe the filter processing + core. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad + minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex + ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate + velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat + cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id + est laborum. type: string initial: Hello domains: @@ -308,24 +305,20 @@ TextArea: BigText2: _label: Programmable Filter - Request information _help: >- - This field allow you enter VTK code and describe the - information pass logic. - Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna - aliqua. Ut enim ad minim veniam, quis nostrud exercitation - ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit - esse cillum dolore eu fugiat nulla pariatur. Excepteur sint - occaecat cupidatat non proident, sunt in culpa qui officia - deserunt mollit anim id est laborum. - Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna - aliqua. Ut enim ad minim veniam, quis nostrud exercitation - ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit - esse cillum dolore eu fugiat nulla pariatur. Excepteur sint - occaecat cupidatat non proident, sunt in culpa qui officia - deserunt mollit anim id est laborum. + This field allow you enter VTK code and describe the information pass + logic. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad + minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex + ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate + velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat + cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id + est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed + do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad + minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex + ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate + velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat + cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id + est laborum. type: string domains: - type: UI @@ -349,14 +342,13 @@ Slider: DoubleInt: _label: Double integers _help: >- - Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna - aliqua. Ut enim ad minim veniam, quis nostrud exercitation - ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit - esse cillum dolore eu fugiat nulla pariatur. Excepteur sint - occaecat cupidatat non proident, sunt in culpa qui officia - deserunt mollit anim id est laborum. + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim + veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea + commodo consequat. Duis aute irure dolor in reprehenderit in voluptate + velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat + cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id + est laborum. type: uint8 size: 2 initial: [5, 10] @@ -368,14 +360,13 @@ Slider: DoubleFloat: _label: Double floats _help: >- - Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna - aliqua. Ut enim ad minim veniam, quis nostrud exercitation - ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit - esse cillum dolore eu fugiat nulla pariatur. Excepteur sint - occaecat cupidatat non proident, sunt in culpa qui officia - deserunt mollit anim id est laborum. + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim + veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea + commodo consequat. Duis aute irure dolor in reprehenderit in voluptate + velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat + cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id + est laborum. type: float64 size: 1 initial: 3.141592654 @@ -387,14 +378,13 @@ Slider: ManyDoubleFloat: _label: Many Double floats _help: >- - Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna - aliqua. Ut enim ad minim veniam, quis nostrud exercitation - ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit - esse cillum dolore eu fugiat nulla pariatur. Excepteur sint - occaecat cupidatat non proident, sunt in culpa qui officia - deserunt mollit anim id est laborum. + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim + veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea + commodo consequat. Duis aute irure dolor in reprehenderit in voluptate + velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat + cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id + est laborum. type: float64 size: -1 initial: diff --git a/examples/03_VTK/app.py b/examples/03_VTK/app.py index c21deda..0b6e8a9 100644 --- a/examples/03_VTK/app.py +++ b/examples/03_VTK/app.py @@ -214,7 +214,10 @@ def import_file(import_file, **kwargs): vuetify.VIcon("mdi-database-export-outline") trame.ClientStateChange( value="export_content", - change="export_content && utils.download('VTKState.json', export_content)", + change=""" + export_content && + utils.download('VTKState.json', export_content) + """, ) html.Span("Export State") diff --git a/examples/04_DynaDomain/model.yaml b/examples/04_DynaDomain/model.yaml index 2d52451..99bd651 100644 --- a/examples/04_DynaDomain/model.yaml +++ b/examples/04_DynaDomain/model.yaml @@ -12,8 +12,8 @@ AdvancedViewExample: type: uint8 initial: 1 domains: - - name: decorator - type: TagDecoratorDomain - properties: - tags: - - "advanced" \ No newline at end of file + - name: decorator + type: TagDecoratorDomain + properties: + tags: + - "advanced" diff --git a/examples/05_ReadonlyDisabled/model.yaml b/examples/05_ReadonlyDisabled/model.yaml index b3cfac7..7415091 100644 --- a/examples/05_ReadonlyDisabled/model.yaml +++ b/examples/05_ReadonlyDisabled/model.yaml @@ -8,14 +8,14 @@ ExampleModel: DisabledInput: _label: Disabled input _help: >- - This input is disabled. It's controlled by setting - disabled="" in the UI XML definition. + This input is disabled. It's controlled by setting disabled="" in the UI + XML definition. type: uint8 initial: 1 ReadonlyInput: _label: Readonly input _help: >- - This input is read-only. It's controlled by setting - readonly="" in the UI XML definition. + This input is read-only. It's controlled by setting readonly="" in the UI + XML definition. type: uint8 initial: 2 diff --git a/examples/06_DynaDropDown/model.yaml b/examples/06_DynaDropDown/model.yaml index 2d67017..b7ae82a 100644 --- a/examples/06_DynaDropDown/model.yaml +++ b/examples/06_DynaDropDown/model.yaml @@ -11,7 +11,7 @@ Item: This is a dropdown type: string domains: - - name: List - type: ListDomain - ui_attributes: {} - widget: sw-select + - name: List + type: ListDomain + ui_attributes: {} + widget: sw-select diff --git a/examples/07_ProxyList/definitions/ui.xml b/examples/07_ProxyList/definitions/ui.xml index 81d3bce..6d1fa4f 100644 --- a/examples/07_ProxyList/definitions/ui.xml +++ b/examples/07_ProxyList/definitions/ui.xml @@ -17,4 +17,4 @@ - \ No newline at end of file + diff --git a/pyproject.toml b/pyproject.toml index 4406dfa..f245e00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,9 +74,3 @@ docstring-code-format = true # This only has an effect when the `docstring-code-format` setting is # enabled. docstring-code-line-length = "dynamic" - -[tool.ruff.lint.pycodestyle] -max-line-length = 120 - -[lint.pydocstyle] -convention = "google" \ No newline at end of file diff --git a/src/trame_simput/core/domains.py b/src/trame_simput/core/domains.py index 87ad2be..eb9f5c7 100644 --- a/src/trame_simput/core/domains.py +++ b/src/trame_simput/core/domains.py @@ -65,7 +65,9 @@ def value(self, v): self._proxy.set_property(self._property_name, v) def valid(self, required_level=2): - """Return true if the current proxy property value is valid for the given level""" + """ + Return true if the current proxy property value is valid for the given level + """ return True @property @@ -89,7 +91,9 @@ def message(self, value): self._message = value def hints(self): - """Return a set of (level, message) when running the validation for the info level""" + """ + Return a set of (level, message) when running the validation for the info level + """ if self.valid(-1): return [] return [ @@ -179,7 +183,8 @@ def set_value(self): _v = data_range[1] else: print( - f"Range domain can't compute {self.__compute}. Expect 'mean', 'min' or 'max' instead." + f"Range domain can't compute {self.__compute}. " + "Expect 'mean', 'min' or 'max' instead." ) prop_size = self._proxy.definition.get(self._property_name).get("size", 1) diff --git a/src/trame_simput/core/proxy.py b/src/trame_simput/core/proxy.py index 944f41c..2eb2557 100644 --- a/src/trame_simput/core/proxy.py +++ b/src/trame_simput/core/proxy.py @@ -455,7 +455,8 @@ def domains_apply(self, *property_names): def domains_state(self): """ Return a serializable state of the domains associated to this proxy. - This include for each property and each domain a `valid` and `available` property. + This include for each property and each domain a `valid` and `available` + property. Also at the property level a list of `hints`. ``` @@ -658,7 +659,8 @@ def create(self, proxy_type, proxy_id=None, existing_obj=None, **initial_values) # Can't create object if no definition available if proxy_type not in self._model_definition: raise ValueError( - f"Object of type: {proxy_type} was not found in our loaded model definitions" + f"Object of type: {proxy_type} was not found in our loaded model" + "definitions" ) self._life_cycle( diff --git a/src/trame_simput/module/.gitignore b/src/trame_simput/module/.gitignore index 5170b04..c8a91ea 100644 --- a/src/trame_simput/module/.gitignore +++ b/src/trame_simput/module/.gitignore @@ -2,4 +2,4 @@ serve serve/*.map serve/*.html serve/*.common.* -serve/*.umd.js \ No newline at end of file +serve/*.umd.js diff --git a/src/trame_simput/widgets/simput.py b/src/trame_simput/widgets/simput.py index 4713479..7d67c8c 100644 --- a/src/trame_simput/widgets/simput.py +++ b/src/trame_simput/widgets/simput.py @@ -13,11 +13,13 @@ def __init__(self, _elem_name, children=None, **kwargs): class Simput(HtmlElement): """ Simput data management component. - This must be registered as the root of a layout to provide children with Simput data. + This must be registered as the root of a layout to provide children with Simput + data. :param ui_manager: See simput docs |simput_link| for more info :param domains_manager: See simput docs |simput_link| for more info - :param prefix: Constructing a Simput component will set several variables, optionally prefixed by a namespace + :param prefix: Constructing a Simput component will set several variables, + optionally prefixed by a namespace :type prefix: str | None :param query: String filtering :type query: str @@ -130,7 +132,8 @@ def auto_update(self, value): class SimputItem(HtmlElement): """ - Simput data display component. This must be child of a Simput component to have access to Simput data. + Simput data display component. + This must be child of a Simput component to have access to Simput data. See simput docs |simput_link| for more info. :param item_id: The simput id of the data to display @@ -139,7 +142,8 @@ class SimputItem(HtmlElement): :type extract: list[str] :param no_ui: Whether to show simput template UI :type no_ui: bool - :param v_slot: Fields to be pass to slot template (i.e.: data, ui, domain, properties, all...) + :param v_slot: Fields to be pass to slot template + (i.e.: data, ui, domain, properties, all...) :type v_slot: str :param children: The children nested within this element :type children: str | list[trame.html.*] | trame.html.* | None diff --git a/vue2-components/.eslintignore b/vue2-components/.eslintignore index a804767..8c35e34 100644 --- a/vue2-components/.eslintignore +++ b/vue2-components/.eslintignore @@ -2,4 +2,4 @@ build/ dist/ node_modules/ .snapshots/ -*.min.js \ No newline at end of file +*.min.js diff --git a/vue2-components/.eslintrc.js b/vue2-components/.eslintrc.js index 5592b18..1080a6c 100644 --- a/vue2-components/.eslintrc.js +++ b/vue2-components/.eslintrc.js @@ -1,14 +1,14 @@ module.exports = { root: true, env: { - node: true + node: true, }, - extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"], + extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'], parserOptions: { - parser: "babel-eslint" + parser: 'babel-eslint', }, rules: { - "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", - "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off" - } + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + }, }; diff --git a/vue2-components/README.md b/vue2-components/README.md index ba1a6ae..1da9443 100644 --- a/vue2-components/README.md +++ b/vue2-components/README.md @@ -1,6 +1,7 @@ # Custom Vue module -This sub-directory capture the client side components that you want to expose inside your trame application. +This sub-directory capture the client side components that you want to expose +inside your trame application. ## Build diff --git a/vue2-components/src/components/SimputItem/template.html b/vue2-components/src/components/SimputItem/template.html index 193cb19..b6008f7 100644 --- a/vue2-components/src/components/SimputItem/template.html +++ b/vue2-components/src/components/SimputItem/template.html @@ -1,5 +1,5 @@