Skip to content

Commit

Permalink
Fix failing mypy check on main (#44191)
Browse files Browse the repository at this point in the history
Failure on main:

```
providers/src/airflow/providers/apache/spark/hooks/spark_submit.py:525: error:
Module "airflow.security.kerberos" has no attribute "get_kerberos_principle";
maybe "get_kerberos_principal"?  [attr-defined]
                from airflow.security.kerberos import (
                ^
providers/src/airflow/providers/apache/spark/hooks/spark_submit.py:525: error:
Name "get_kerberos_principal" already defined (possibly by an import)
[no-redef]
                from airflow.security.kerberos import (
                ^
Found 2 errors in 1 file (checked 3337 source files)
Error 1 returned
```
  • Loading branch information
kaxil authored Nov 19, 2024
1 parent 86c4c6f commit 7747b7b
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,14 @@ def _build_track_driver_status_command(self) -> list[str]:
def _resolve_kerberos_principal(self, principal: str | None) -> str:
"""Resolve kerberos principal."""
# todo: remove try/exception when min airflow version is 3.0
try:
from airflow.security.kerberos import get_kerberos_principal # type: ignore[attr-defined]
except ImportError:
from airflow.security.kerberos import (
get_kerberos_principle as get_kerberos_principal, # type: ignore[attr-defined]
)
from airflow.security import kerberos

return get_kerberos_principal(principal)
try:
func = kerberos.get_kerberos_principal
except AttributeError:
# Fallback for older versions of Airflow
func = kerberos.get_kerberos_principle # type: ignore[attr-defined]
return func(principal)

def submit(self, application: str = "", **kwargs: Any) -> None:
"""
Expand Down

0 comments on commit 7747b7b

Please sign in to comment.