From dce1381f7f40b87bbb0191c90d06420f96c32570 Mon Sep 17 00:00:00 2001 From: Adam Lewis <23342526+Adam-D-Lewis@users.noreply.github.com> Date: Thu, 1 Aug 2024 20:28:25 -0500 Subject: [PATCH] add typos spell checker to pre-commit (#2568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: MichaƂ Krassowski <5832902+krassowski@users.noreply.github.com> --- .github/workflows/test_azure_integration.yaml | 2 +- .github/workflows/test_helm_charts.yaml | 2 +- .pre-commit-config.yaml | 5 +++++ RELEASE.md | 2 +- pyproject.toml | 6 ++++++ pytest.ini | 2 +- src/_nebari/stages/infrastructure/__init__.py | 16 ++++++++-------- .../infrastructure/template/aws/variables.tf | 2 +- .../template/gcp/modules/kubernetes/outputs.tf | 2 +- .../dask-gateway/files/gateway_config.py | 2 +- tests/common/run_notebook.py | 18 +++++++++--------- tests/tests_unit/test_schema.py | 4 ++-- 12 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test_azure_integration.yaml b/.github/workflows/test_azure_integration.yaml index 4579fe8471..fbb0231015 100644 --- a/.github/workflows/test_azure_integration.yaml +++ b/.github/workflows/test_azure_integration.yaml @@ -1,4 +1,4 @@ -name: Azure Delpoyment +name: Azure Deployment on: schedule: diff --git a/.github/workflows/test_helm_charts.yaml b/.github/workflows/test_helm_charts.yaml index 1d86eb92e4..3f0ed8834e 100644 --- a/.github/workflows/test_helm_charts.yaml +++ b/.github/workflows/test_helm_charts.yaml @@ -1,5 +1,5 @@ # Right now the trigger is set to run on every Monday at 13:00 UTC, -# or when the workflow file is modified. An aditional manual trigger +# or when the workflow file is modified. An additional manual trigger # is also available. name: "Validate Helm Charts downloads" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 96795fb231..26e4a44e4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,6 +36,11 @@ repos: - id: check-executables-have-shebangs exclude: "^src/_nebari/template/" + - repo: https://github.com/crate-ci/typos + rev: v1.23.2 + hooks: + - id: typos + - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: diff --git a/RELEASE.md b/RELEASE.md index a6cd9deacf..90ccc14f67 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -285,7 +285,7 @@ command and follow the instructions * paginator for boto3 ec2 instance types by @sblair-metrostar in https://github.com/nebari-dev/nebari/pull/1923 * Update README.md -- fix typo. by @teoliphant in https://github.com/nebari-dev/nebari/pull/1925 * Add more unit tests, add cleanup step for Digital Ocean integration test by @iameskild in https://github.com/nebari-dev/nebari/pull/1910 -* Add cleanup step for AWS integration test, ensure diable_prompt is passed through by @iameskild in https://github.com/nebari-dev/nebari/pull/1921 +* Add cleanup step for AWS integration test, ensure disable_prompt is passed through by @iameskild in https://github.com/nebari-dev/nebari/pull/1921 * K8s 1.25 + More Improvements by @Adam-D-Lewis in https://github.com/nebari-dev/nebari/pull/1856 * adding lifecycle ignore to eks node group by @sblair-metrostar in https://github.com/nebari-dev/nebari/pull/1905 * nebari init unit tests by @sblair-metrostar in https://github.com/nebari-dev/nebari/pull/1931 diff --git a/pyproject.toml b/pyproject.toml index 844c57e415..c0dd0fedeb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -177,3 +177,9 @@ exclude_also = [ "@(abc\\.)?abstractmethod", ] ignore_errors = false + +[tool.typos] +files.extend-exclude = ["_build", "*/build/*", "*/node_modules/*", "nebari.egg-info", "*.git", "*.js", "*.json", "*.yaml", "*.yml", "pre-commit-config.yaml"] +default.extend-ignore-re = ["(?Rm)^.*(#|//)\\s*typos: ignore$"] +default.extend-ignore-words-re = ["aks", "AKS"] +default.check-filename = false # Turn off initially, enable once https://github.com/nebari-dev/nebari/issues/2598 is addressed diff --git a/pytest.ini b/pytest.ini index 0555ec6b2d..d299f154a8 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,6 +1,6 @@ [pytest] addopts = - # show tests that (f)ailed, (E)rror, or (X)passed in the summary + # show tests that (f)ailed, (E)rror, or (X)passed in the summary # typos: ignore -rfEX # Make tracebacks shorter --tb=native diff --git a/src/_nebari/stages/infrastructure/__init__.py b/src/_nebari/stages/infrastructure/__init__.py index 8b188a720b..1a16238b1b 100644 --- a/src/_nebari/stages/infrastructure/__init__.py +++ b/src/_nebari/stages/infrastructure/__init__.py @@ -340,10 +340,10 @@ class GoogleCloudPlatformProvider(schema.Base): @classmethod def _check_input(cls, data: Any) -> Any: google_cloud.check_credentials() - avaliable_regions = google_cloud.regions() - if data["region"] not in avaliable_regions: + available_regions = google_cloud.regions() + if data["region"] not in available_regions: raise ValueError( - f"Google Cloud region={data['region']} is not one of {avaliable_regions}" + f"Google Cloud region={data['region']} is not one of {available_regions}" ) available_kubernetes_versions = google_cloud.kubernetes_versions(data["region"]) @@ -584,16 +584,16 @@ def check_provider(cls, data: Any) -> Any: f"'{provider}' is not a valid enumeration member; permitted: local, existing, do, aws, gcp, azure" ) else: - setted_providers = [ + set_providers = [ provider for provider in provider_name_abbreviation_map.keys() if provider in data ] - num_providers = len(setted_providers) + num_providers = len(set_providers) if num_providers > 1: - raise ValueError(f"Multiple providers set: {setted_providers}") + raise ValueError(f"Multiple providers set: {set_providers}") elif num_providers == 1: - data["provider"] = provider_name_abbreviation_map[setted_providers[0]] + data["provider"] = provider_name_abbreviation_map[set_providers[0]] elif num_providers == 0: data["provider"] = schema.ProviderEnum.local.value return data @@ -606,7 +606,7 @@ class NodeSelectorKeyValue(schema.Base): class KubernetesCredentials(schema.Base): host: str - cluster_ca_certifiate: str + cluster_ca_certifiate: str # ignored for now. More info in https://github.com/nebari-dev/nebari/issues/2597. # typos: ignore token: Optional[str] = None username: Optional[str] = None password: Optional[str] = None diff --git a/src/_nebari/stages/infrastructure/template/aws/variables.tf b/src/_nebari/stages/infrastructure/template/aws/variables.tf index c07c8f60f2..2e80c64c3c 100644 --- a/src/_nebari/stages/infrastructure/template/aws/variables.tf +++ b/src/_nebari/stages/infrastructure/template/aws/variables.tf @@ -47,7 +47,7 @@ variable "availability_zones" { } variable "vpc_cidr_block" { - description = "VPC cidr block for infastructure" + description = "VPC cidr block for infrastructure" type = string } diff --git a/src/_nebari/stages/infrastructure/template/gcp/modules/kubernetes/outputs.tf b/src/_nebari/stages/infrastructure/template/gcp/modules/kubernetes/outputs.tf index bfb5463295..513294aac7 100644 --- a/src/_nebari/stages/infrastructure/template/gcp/modules/kubernetes/outputs.tf +++ b/src/_nebari/stages/infrastructure/template/gcp/modules/kubernetes/outputs.tf @@ -1,5 +1,5 @@ output "credentials" { - description = "Credentials required for connecting to kubernets cluster" + description = "Credentials required for connecting to kubernetes cluster" sensitive = true value = { endpoint = "https://${google_container_cluster.main.endpoint}" diff --git a/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/dask-gateway/files/gateway_config.py b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/dask-gateway/files/gateway_config.py index 2219d14e56..c58e3aa90d 100644 --- a/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/dask-gateway/files/gateway_config.py +++ b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/dask-gateway/files/gateway_config.py @@ -129,7 +129,7 @@ def base_node_group(options): default_node_group if worker_node_group is None else worker_node_group ) - # check `schduler_extra_pod_config` first + # check `scheduler_extra_pod_config` first scheduler_node_group = ( config["profiles"][options.profile] .get("scheduler_extra_pod_config", {}) diff --git a/tests/common/run_notebook.py b/tests/common/run_notebook.py index 019fd26710..0c39f4b5ac 100644 --- a/tests/common/run_notebook.py +++ b/tests/common/run_notebook.py @@ -20,7 +20,7 @@ def run( expected_outputs: List[str], conda_env: str, timeout: float = 1000, - complition_wait_time: float = 2, + completion_wait_time: float = 2, retry: int = 2, retry_wait_time: float = 5, exact_match: bool = True, @@ -47,7 +47,7 @@ def run( timeout: float Time in seconds to wait for the expected output text to appear. default: 1000 - complition_wait_time: float + completion_wait_time: float Time in seconds to wait between checking for expected output text. default: 2 retry: int @@ -77,7 +77,7 @@ def run( self._restart_run_all() # Wait for a couple of seconds to make sure it's re-started time.sleep(retry_wait_time) - self._wait_for_commands_completion(timeout, complition_wait_time) + self._wait_for_commands_completion(timeout, completion_wait_time) all_outputs = self._get_outputs() assert_match_all_outputs(expected_outputs, all_outputs, exact_match) @@ -126,7 +126,7 @@ def assert_code_output( code: str, expected_output: str, timeout: float = 1000, - complition_wait_time: float = 2, + completion_wait_time: float = 2, exact_match: bool = True, ): """ @@ -143,11 +143,11 @@ def assert_code_output( timeout: float Time in seconds to wait for the expected output text to appear. default: 1000 - complition_wait_time: float + completion_wait_time: float Time in seconds to wait between checking for expected output text. """ self.run_in_last_cell(code) - self._wait_for_commands_completion(timeout, complition_wait_time) + self._wait_for_commands_completion(timeout, completion_wait_time) outputs = self._get_outputs() actual_output = outputs[-1] if outputs else "" assert_match_output(expected_output, actual_output, exact_match) @@ -177,7 +177,7 @@ def _get_last_cell(self): raise ValueError("Unable to get last cell") def _wait_for_commands_completion( - self, timeout: float, complition_wait_time: float + self, timeout: float, completion_wait_time: float ): """ Wait for commands to finish running @@ -186,7 +186,7 @@ def _wait_for_commands_completion( ---------- timeout: float Time in seconds to wait for the expected output text to appear. - complition_wait_time: float + completion_wait_time: float Time in seconds to wait between checking for expected output text. """ elapsed_time = 0.0 @@ -198,7 +198,7 @@ def _wait_for_commands_completion( if not still_visible: break elapsed_time = time.time() - start_time - time.sleep(complition_wait_time) + time.sleep(completion_wait_time) if still_visible: raise ValueError( f"Timeout Waited for commands to finish, " diff --git a/tests/tests_unit/test_schema.py b/tests/tests_unit/test_schema.py index 446b6d1085..fa6a0c747c 100644 --- a/tests/tests_unit/test_schema.py +++ b/tests/tests_unit/test_schema.py @@ -139,7 +139,7 @@ def test_multiple_providers(config_schema): config_schema(**config_dict) -def test_aws_premissions_boundary(config_schema): +def test_aws_permissions_boundary(config_schema): permissions_boundary = "arn:aws:iam::123456789012:policy/MyBoundaryPolicy" config_dict = { "project_name": "test", @@ -156,7 +156,7 @@ def test_aws_premissions_boundary(config_schema): @pytest.mark.parametrize("provider", ["local", "existing"]) -def test_setted_provider(config_schema, provider): +def test_set_provider(config_schema, provider): config_dict = { "project_name": "test", "provider": provider,