bito-code-review[bot] commented on PR #43499:
URL: https://github.com/apache/superset/pull/43499#issuecomment-5405295330
<!-- Bito Reply -->
The flagged issue is correct. The `label` property in `SavedQuery` is
nullable, but the new `name` property is annotated to return a `str`, which can
lead to runtime errors or `None` values being stored where a string is
expected. To resolve this, you should provide a non-null fallback (e.g., an
empty string) and update the return type annotation to reflect that it may be
optional if `label` is missing.
Here is the corrected implementation for `superset/models/sql_lab.py`:
```python
@property
def name(self) -> str:
"""
Expose ``label`` as ``name`` so callers that treat a ``SavedQuery``
as
a generic datasource (e.g. chart create/update commands) can rely on
a uniform ``name`` attribute across all datasource types.
"""
return self.label or ""
```
There are no other comments on this PR to address. Would you like me to
check for any other potential issues in the codebase?
**superset/models/sql_lab.py**
```
@property
def name(self) -> str:
"""
Expose ``label`` as ``name`` so callers that treat a ``SavedQuery``
as
a generic datasource (e.g. chart create/update commands) can rely on
a uniform ``name`` attribute across all datasource types.
"""
return self.label or ""
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]