diff --git a/requirements/docs.txt b/requirements/docs.txt index c2546d51..17b7ede7 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -234,9 +234,9 @@ mkdocs-get-deps==0.2.0 \ mkdocs-git-revision-date-plugin==0.3.2 \ --hash=sha256:2e67956cb01823dd2418e2833f3623dee8604cdf223bddd005fe36226a56f6ef # via -r docs.in -mkdocs-material==9.7.6 \ - --hash=sha256:00bdde50574f776d328b1862fe65daeaf581ec309bd150f7bff345a098c64a69 \ - --hash=sha256:71b84353921b8ea1ba84fe11c50912cc512da8fe0881038fcc9a0761c0e635ba +mkdocs-material==9.7.7 \ + --hash=sha256:8ea9bb1737a5b524a5f9dcf2e1b4ebda8274ae3008aa7845720a97083bef708f \ + --hash=sha256:c0649c065b1b0512d60aad8c10f947f8e455284475239b364b610f2deb4d0855 # via -r docs.in mkdocs-material-extensions==1.3.1 \ --hash=sha256:10c9511cea88f568257f960358a467d12b970e1f7b2c0e5fb2bb48cab1928443 \ diff --git a/src/django_errors/mail_identity.py b/src/django_errors/mail_identity.py index 5cc380fa..b4866461 100644 --- a/src/django_errors/mail_identity.py +++ b/src/django_errors/mail_identity.py @@ -39,23 +39,43 @@ def _read_env_file(path: str | Path) -> dict[str, str]: def identity_tag( *, - scope: Optional[str] = None, - role: Optional[str] = None, - hostname: Optional[str] = None, - install_tag: Optional[str] = None, + scope: str | None = None, + role: str | None = None, + hostname: str | None = None, + install_tag: str | None = None, env_file: str | Path = _DEFAULT_ENV_FILE, - environ: Optional[Mapping[str, str]] = None, + environ: Mapping[str, str] | None = None, ) -> str: """Return the compact identity tag for this host.""" env = environ if environ is not None else os.environ file_vars = _read_env_file(env_file) - cached = (env.get("SH_MAIL_IDENTITY_TAG") or file_vars.get("SH_MAIL_IDENTITY_TAG") or "").strip() - if cached and scope is None and role is None and hostname is None and install_tag is None: + cached = ( + env.get("SH_MAIL_IDENTITY_TAG") + or file_vars.get("SH_MAIL_IDENTITY_TAG") + or "" + ).strip() + if ( + cached + and scope is None + and role is None + and hostname is None + and install_tag is None + ): return cached - scope_v = (scope or env.get("SH_OS_Scope") or file_vars.get("SH_OS_Scope") or "unknown").strip() - role_v = (role or env.get("SH_Host_Role") or file_vars.get("SH_Host_Role") or "unknown").strip() + scope_v = ( + scope + or env.get("SH_OS_Scope") + or file_vars.get("SH_OS_Scope") + or "unknown" + ).strip() + role_v = ( + role + or env.get("SH_Host_Role") + or file_vars.get("SH_Host_Role") + or "unknown" + ).strip() host_v = ( hostname or env.get("SH_OS_HostName") @@ -65,7 +85,11 @@ def identity_tag( install_v = ( install_tag if install_tag is not None - else (env.get("SH_Mail_InstallTag") or file_vars.get("SH_Mail_InstallTag") or "") + else ( + env.get("SH_Mail_InstallTag") + or file_vars.get("SH_Mail_InstallTag") + or "" + ) ).strip() if scope_v == "PROD" and role_v in _PROD_COMPACT_ROLES: @@ -80,13 +104,17 @@ def identity_tag( def subject_prefix( kind: str = "app", *, - environ: Optional[Mapping[str, str]] = None, + environ: Mapping[str, str] | None = None, env_file: str | Path = _DEFAULT_ENV_FILE, ) -> str: """Return ``[kind]`` with trailing space (Django EMAIL_SUBJECT_PREFIX).""" env = environ if environ is not None else os.environ file_vars = _read_env_file(env_file) - explicit = (env.get("EMAIL_SUBJECT_PREFIX") or file_vars.get("EMAIL_SUBJECT_PREFIX") or "").rstrip() + explicit = ( + env.get("EMAIL_SUBJECT_PREFIX") + or file_vars.get("EMAIL_SUBJECT_PREFIX") + or "" + ).rstrip() if explicit and kind == "app": return f"{explicit} " if not explicit.endswith(" ") else explicit return f"[{kind}]{identity_tag(environ=env, env_file=env_file)} "