Skip to content

Commit 0db194c

Browse files
razvandervoeti
authored andcommitted
fix: make airflow opa auth manager compatible with python 3.9 (#1001)
1 parent 0e46092 commit 0db194c

File tree

4 files changed

+194
-21
lines changed

4 files changed

+194
-21
lines changed

airflow/opa-auth-manager/opa_auth_manager/opa_fab_auth_manager.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from airflow.stats import Stats
1919
from airflow.utils.log.logging_mixin import LoggingMixin
2020
from cachetools import TTLCache, cachedmethod
21-
from typing import override
21+
from typing import Optional, Union
22+
from overrides import override
2223
import json
2324
import requests
2425

@@ -132,8 +133,8 @@ def is_authorized_configuration(
132133
self,
133134
*,
134135
method: ResourceMethod,
135-
details: ConfigurationDetails | None = None,
136-
user: BaseUser | None = None,
136+
details: Optional[ConfigurationDetails] = None,
137+
user: Optional[BaseUser] = None,
137138
) -> bool:
138139
"""
139140
Return whether the user is authorized to perform a given action on
@@ -178,8 +179,8 @@ def is_authorized_connection(
178179
self,
179180
*,
180181
method: ResourceMethod,
181-
details: ConnectionDetails | None = None,
182-
user: BaseUser | None = None,
182+
details: Optional[ConnectionDetails] = None,
183+
user: Optional[BaseUser] = None,
183184
) -> bool:
184185
"""
185186
Return whether the user is authorized to perform a given action on a connection.
@@ -223,9 +224,9 @@ def is_authorized_dag(
223224
self,
224225
*,
225226
method: ResourceMethod,
226-
access_entity: DagAccessEntity | None = None,
227-
details: DagDetails | None = None,
228-
user: BaseUser | None = None,
227+
access_entity: Optional[DagAccessEntity] = None,
228+
details: Optional[DagDetails] = None,
229+
user: Optional[BaseUser] = None,
229230
) -> bool:
230231
"""
231232
Return whether the user is authorized to perform a given action on a DAG.
@@ -277,8 +278,8 @@ def is_authorized_dataset(
277278
self,
278279
*,
279280
method: ResourceMethod,
280-
details: DatasetDetails | None = None,
281-
user: BaseUser | None = None,
281+
details: Optional[DatasetDetails] = None,
282+
user: Optional[BaseUser] = None,
282283
) -> bool:
283284
"""
284285
Return whether the user is authorized to perform a given action on a dataset.
@@ -322,8 +323,8 @@ def is_authorized_pool(
322323
self,
323324
*,
324325
method: ResourceMethod,
325-
details: PoolDetails | None = None,
326-
user: BaseUser | None = None,
326+
details: Optional[PoolDetails] = None,
327+
user: Optional[BaseUser] = None,
327328
) -> bool:
328329
"""
329330
Return whether the user is authorized to perform a given action on a pool.
@@ -367,8 +368,8 @@ def is_authorized_variable(
367368
self,
368369
*,
369370
method: ResourceMethod,
370-
details: VariableDetails | None = None,
371-
user: BaseUser | None = None,
371+
details: Optional[VariableDetails] = None,
372+
user: Optional[BaseUser] = None,
372373
) -> bool:
373374
"""
374375
Return whether the user is authorized to perform a given action on a variable.
@@ -412,7 +413,7 @@ def is_authorized_view(
412413
self,
413414
*,
414415
access_view: AccessView,
415-
user: BaseUser | None = None,
416+
user: Optional[BaseUser] = None,
416417
) -> bool:
417418
"""
418419
Return whether the user is authorized to access a read-only state of the installation.
@@ -446,9 +447,9 @@ def is_authorized_view(
446447
def is_authorized_custom_view(
447448
self,
448449
*,
449-
method: ResourceMethod | str,
450+
method: Union[ResourceMethod, str],
450451
resource_name: str,
451-
user: BaseUser | None = None,
452+
user: Optional[BaseUser] = None,
452453
) -> bool:
453454
"""
454455
Return whether the user is authorized to perform a given action on a custom view.

0 commit comments

Comments
 (0)