diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-dev.yml index 1c0fd5a..3ac9ec3 100644 --- a/.github/workflows/ci-dev.yml +++ b/.github/workflows/ci-dev.yml @@ -20,9 +20,13 @@ jobs: python -m pip install --upgrade pip pip install flake8==4.0.1 pip install bandit==1.7.8 + pip install codespell==2.2.4 - name: Run Flake8 run: | flake8 - name: Run Bandit run: | bandit -r . + - name: Run Spell Check + run: | + codespell --skip="*.md,venv,migrations,*.pyc" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 32598d0..d6a891b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,3 +19,8 @@ repos: - id: bandit args: ["-r", ".", "-x", "**/venv/*"] pass_filenames: false + - repo: https://github.com/codespell-project/codespell + rev: v2.2.4 + hooks: + - id: codespell + args: ['--skip=*.md,venv,migrations,*.pyc'] diff --git a/common/apps/organization/tasks.py b/common/apps/organization/tasks.py index 94e6f79..e44d241 100644 --- a/common/apps/organization/tasks.py +++ b/common/apps/organization/tasks.py @@ -20,7 +20,9 @@ def get_new_organization_handler(): @task(name="spacedf.tasks.new_organization", max_retries=3) @transaction.atomic def create_organization(id, name, slug_name, is_active, owner, created_at, updated_at): - logger.info(f"create_organization: owner_email={owner.get('email')}, org_slug={slug_name}") + logger.info( + f"create_organization: owner_email={owner.get('email')}, org_slug={slug_name}" + ) organization = Organization( schema_name=slug_name, diff --git a/common/celery/tasks.py b/common/celery/tasks.py index 6eaf057..1dc1807 100644 --- a/common/celery/tasks.py +++ b/common/celery/tasks.py @@ -28,8 +28,8 @@ def inner(self, **kwargs): handler(self=self, **kwargs) else: handler(**kwargs) - except Exception as ex: - logger.exception(ex) + except Exception as e: + logger.exception(e) self.retry(countdown=3**self.request.retries) return inner diff --git a/common/rabitmq/rabbitmq_provisioner.py b/common/rabitmq/rabbitmq_provisioner.py index b38c4bc..c7f3320 100644 --- a/common/rabitmq/rabbitmq_provisioner.py +++ b/common/rabitmq/rabbitmq_provisioner.py @@ -69,8 +69,8 @@ def list_vhosts(self) -> Set[str]: for entry in response.json() if entry.get("name") is not None } - except requests.RequestException as exc: # noqa: BLE001 - logger.error("Failed to list RabbitMQ vhosts: %s", exc) + except requests.RequestException as e: + logger.error("Failed to list RabbitMQ vhosts: %s", e) return set() def get_vhost_load(self, vhost_name: str) -> Dict: @@ -181,11 +181,9 @@ def create_vhost(self, vhost_name: str) -> bool: vhost=vhost_name, connector_name=emqx_client.connector_name(vhost_name), ) - except Exception as exc: # noqa: BLE001 + except Exception as e: logger.warning( - "Failed to configure EMQX connector for new vhost %s: %s", - vhost_name, - exc, + f"Failed to configure EMQX connector for new vhost {vhost_name}: {str(e)}" ) return True except requests.RequestException as e: @@ -357,9 +355,9 @@ def get_organization_slugs( ) return slugs - except Exception as exc: + except Exception as e: logger.warning( - f"Failed to retrieve organization slugs for vhost {vhost_name}: {exc}" + f"Failed to retrieve organization slugs for vhost {vhost_name}: {e}" ) if exclude: return [] @@ -478,11 +476,9 @@ def provision_tenant( ) emqx_client.ensure_vhost_rule(vhost_name, existing_slugs) - except Exception as exc: # noqa: BLE001 + except Exception as e: logger.error( - "Failed to configure EMQX resources for org %s: %s", - org_slug, - exc, + f"Failed to configure EMQX resources for org {org_slug}: {str(e)}" ) return { @@ -566,11 +562,9 @@ def delete_tenant(self, vhost_name: str, org_slug: str = None) -> bool: ) emqx_client.teardown_tenant(vhost_name, remaining_slugs) - except Exception as exc: # noqa: BLE001 + except Exception as e: logger.warning( - "Failed to teardown EMQX resources for org %s: %s", - org_slug, - exc, + f"Failed to teardown EMQX resources for org {org_slug}: {str(e)}" ) return True