From c46ceadec3b96e2f067a9af7e4b609e29ef6baeb Mon Sep 17 00:00:00 2001 From: Tony Meyer Date: Tue, 24 Sep 2024 16:09:03 +1200 Subject: [PATCH] Spell-check the code as part of linting. --- .pre-commit-config.yaml | 9 ++++++++- CODE_OF_CONDUCT.md | 2 +- ops/_private/harness.py | 2 +- ops/model.py | 4 ++-- pyproject.toml | 4 ++++ tox.ini | 2 ++ 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d4ed43f22..1649f28d4 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-ast @@ -24,3 +24,10 @@ repos: args: [ --preview ] - id: ruff-format args: [ --preview ] + # Spellcheck the code. + - repo: https://github.com/codespell-project/codespell + rev: v2.2.4 + hooks: + - id: codespell + additional_dependencies: + - tomli diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index b5bc1b1f8..073221512 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal +level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards diff --git a/ops/_private/harness.py b/ops/_private/harness.py index 09334406e..c762b454a 100644 --- a/ops/_private/harness.py +++ b/ops/_private/harness.py @@ -380,7 +380,7 @@ def begin(self) -> None: if self._charm is not None: raise RuntimeError('cannot call the begin method on the harness more than once') - # The Framework adds attributes to class objects for events, etc. As such, we can't re-use + # The Framework adds attributes to class objects for events, etc. As such, we can't reuse # the original class against multiple Frameworks. So create a locally defined class # and register it. # TODO: jam 2020-03-16 We are looking to changes this to Instance attributes instead of diff --git a/ops/model.py b/ops/model.py index d03c4b584..3cc268f6b 100644 --- a/ops/model.py +++ b/ops/model.py @@ -3133,7 +3133,7 @@ def _format_action_result_dict( parent_key: Optional[str] = None, output: Optional[Dict[str, str]] = None, ) -> Dict[str, str]: - """Turn a nested dictionary into a flattened dictionary, using '.' as a key seperator. + """Turn a nested dictionary into a flattened dictionary, using '.' as a key separator. This is used to allow nested dictionaries to be translated into the dotted format required by the Juju `action-set` hook tool in order to set nested data on an action. @@ -3973,7 +3973,7 @@ class CloudSpec: """A list of CA certificates.""" skip_tls_verify: bool = False - """Whether to skip TLS verfication.""" + """Whether to skip TLS verification.""" is_controller_cloud: bool = False """If this is the cloud used by the controller, defaults to False.""" diff --git a/pyproject.toml b/pyproject.toml index 4bfa2d1db..237962926 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -224,3 +224,7 @@ reportUnnecessaryComparison = false reportUnnecessaryTypeIgnoreComment = "error" disableBytesTypePromotions = false stubPath = "" + +[tool.codespell] +skip = './docs/_build,.venv,venv,build' +quiet-level = 3 diff --git a/tox.ini b/tox.ini index cf097a12f..505aa79bb 100644 --- a/tox.ini +++ b/tox.ini @@ -68,9 +68,11 @@ commands = description = Check code against coding style standards deps = ruff==0.4.5 + codespell==2.3.0 commands = ruff check --preview ruff format --preview --check + codespell [testenv:static] description = Run static type checker