uranusjr commented on code in PR #36275:
URL: https://github.com/apache/airflow/pull/36275#discussion_r1431007722
##########
airflow/auth/managers/base_auth_manager.py:
##########
@@ -99,13 +99,13 @@ def get_user_display_name(self) -> str:
def get_user(self) -> BaseUser | None:
"""Return the user associated to the user in session."""
- def get_user_id(self) -> str:
+ def get_user_id(self) -> str | None:
"""Return the user ID associated to the user in session."""
user = self.get_user()
if not user:
self.log.error("Calling 'get_user_id()' but the user is not signed
in.")
raise AirflowException("The user must be signed in.")
- return str(user.get_id())
+ return str(user.get_id()) if user.get_id() else None
Review Comment:
```suggestion
if (user_id := user.get_id()):
return str(user_id)
return None
```
Depending on the auth backend, the function may not be cheap.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]