gopidesupavan commented on code in PR #53436:
URL: https://github.com/apache/airflow/pull/53436#discussion_r2211557610
##########
providers/fab/src/airflow/providers/fab/auth_manager/security_manager/override.py:
##########
@@ -1551,15 +1551,15 @@ def delete_action(self, name: str) -> bool:
---------------
"""
- def get_resource(self, name: str) -> Resource:
+ def get_resource(self, name: str) -> Resource | None:
"""
Return a resource record by name, if it exists.
:param name: Name of resource
"""
return
self.get_session.query(self.resource_model).filter_by(name=name).one_or_none()
- def create_resource(self, name) -> Resource:
+ def create_resource(self, name) -> Resource | None:
Review Comment:
This is bit interesting one :)
First we need to tell mypy possible return None we get from the
`get_resource` call.
If we get None from `get_resource` call and if something fails in the try
block then this methods returns `resource` that has None. in exception we are
just logging so this method either returns `Resource` or None (when anything
fails in try)
https://github.com/apache/airflow/blob/5ca58d6b8f8184d85e7db59cb988c7d0cd60f61d/providers/fab/src/airflow/providers/fab/auth_manager/security_manager/override.py#L1568-L1579
--
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]