diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1544a77ee..66f6a7314 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-added-large-files - id: check-merge-conflict @@ -37,36 +37,36 @@ repos: # Linter for json, yaml, md, css and more - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.9-for-vscode + rev: v4.0.0-alpha.8 hooks: - id: prettier - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: d2425a6 + rev: v2.12.0 hooks: - id: pretty-format-toml args: [--autofix] - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.261 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.9 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/PyCQA/bandit - rev: 1.7.5 + rev: 1.7.6 hooks: - id: bandit args: [-c, pyproject.toml, -ll] additional_dependencies: ["bandit[toml]"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.2.0 + rev: v1.8.0 hooks: - id: mypy files: ^vizro-core/src/ @@ -74,7 +74,7 @@ repos: - pydantic>=1.10.13, <2 # deliberately pinned to <2 until we bump our pydantic requirement to strictly >=2 - repo: https://github.com/gitleaks/gitleaks - rev: v8.16.4 + rev: v8.18.1 hooks: - id: gitleaks name: gitleaks (protect) diff --git a/pyproject.toml b/pyproject.toml index d7f60423a..67f403dfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,9 +68,12 @@ target-version = "py38" known-first-party = ["vizro"] [tool.ruff.per-file-ignores] +# Ignore current false positives for pydantic models subclassing across files +# See: https://github.com/astral-sh/ruff/issues/5243#issuecomment-1860776975 +"**/models/**" = ["RUF012"] # Tests can use magic values, assertions, and relative imports, ignore missing docstrings, # compare to empty string -"**/tests/**" = ["PLR2004", "S101", "TID252", "D100", "D101", "D102", "D103", "PLC1901"] +"**/tests/**" = ["PLR2004", "S101", "TID252", "D100", "D101", "D102", "D103", "PLC1901", "RUF012"] # Ignore import violations in all __init__.py files "__init__.py" = ["E402", "F401"] diff --git a/tools/check_package_release.py b/tools/check_package_release.py index d28af2534..31a389b12 100644 --- a/tools/check_package_release.py +++ b/tools/check_package_release.py @@ -54,6 +54,6 @@ def _check_no_dev_version(package_name, package_version): package_version = attempted_package_version with open(env_file, "a") as f: - f.write(f"NEW_RELEASE={str(new_release)}\n") + f.write(f"NEW_RELEASE={new_release!s}\n") if new_release: f.write(f"PACKAGE_NAME={package_name}\nPACKAGE_VERSION={package_version}\n") diff --git a/vizro-core/changelog.d/20240102_095818_huong_li_nguyen_pre_commit_ci_update_config.md b/vizro-core/changelog.d/20240102_095818_huong_li_nguyen_pre_commit_ci_update_config.md new file mode 100644 index 000000000..f1f65e73c --- /dev/null +++ b/vizro-core/changelog.d/20240102_095818_huong_li_nguyen_pre_commit_ci_update_config.md @@ -0,0 +1,48 @@ + + + + + + + + + diff --git a/vizro-core/src/vizro/models/_base.py b/vizro-core/src/vizro/models/_base.py index f25792b5e..24614d194 100644 --- a/vizro-core/src/vizro/models/_base.py +++ b/vizro-core/src/vizro/models/_base.py @@ -71,7 +71,7 @@ def _is_discriminated_union(field): new_annotation = _add_to_discriminated_union(field.outer_type_) elif sub_field is not None and _is_discriminated_union(sub_field): # Field is a list of discriminated union e.g. components: List[ComponentType]. - new_annotation = List[_add_to_discriminated_union(sub_field.outer_type_)] # type: ignore[misc,index] + new_annotation = List[_add_to_discriminated_union(sub_field.outer_type_)] # type: ignore[misc] else: raise ValueError( f"Field '{field_name}' must be a discriminated union or list of discriminated union type. " diff --git a/vizro-core/src/vizro/models/_components/_form.py b/vizro-core/src/vizro/models/_components/_form.py index cbf9b7142..a587907e6 100644 --- a/vizro-core/src/vizro/models/_components/_form.py +++ b/vizro-core/src/vizro/models/_components/_form.py @@ -84,8 +84,8 @@ def _make_form_layout(self, component_container): style={ "gridRowGap": self.layout.row_gap, "gridColumnGap": self.layout.col_gap, - "gridTemplateColumns": f"repeat({len(self.layout.grid[0])}, minmax({self.layout.col_min_width}, 1fr))", # noqa: E501 - "gridTemplateRows": f"repeat({len(self.layout.grid)}, minmax({self.layout.row_min_height}, 1fr))", # noqa: E501 + "gridTemplateColumns": f"repeat({len(self.layout.grid[0])}, minmax({self.layout.col_min_width}, 1fr))", + "gridTemplateRows": f"repeat({len(self.layout.grid)}, minmax({self.layout.row_min_height}, 1fr))", }, className="component_container_grid", id=self.id, @@ -93,7 +93,7 @@ def _make_form_layout(self, component_container): if __name__ == "__main__": - from vizro.models import Layout # noqa: F811 + from vizro.models import Layout Form.update_forward_refs(Layout=Layout)