You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "bito-code-review[bot] (via GitHub)" <gi...@apache.org> on 2026/10/01 07:35:20 UTC

Re: [PR] fix(mypy): make UUIDMixin.uuid's nullable type resolve deterministically [superset]

bito-code-review[bot] commented on PR #44817:
URL: https://github.com/apache/superset/pull/44817#issuecomment-5926908843

   <!-- Bito Reply -->
   Yes, creating a standalone mypy fixture is an excellent way to verify this type inference. By defining a minimal class using `UUIDMixin` and asserting the type of `Dashboard.uuid` (or an instance's `.uuid` attribute) in a test file, you can ensure that mypy correctly identifies it as `UUID | None` without relying on the full repository context. If the `@declared_attr` implementation is reverted, the type would likely revert to `Any` or `Column[Any]`, causing the assertion to fail and confirming the regression is caught.
   
   **tests/mypy_test_uuid.py**
   ```
   from typing import Optional
   from uuid import UUID
   from superset.models.helpers import UUIDMixin
   
   class Dashboard(UUIDMixin):
       pass
   
   def test_uuid_type() -> None:
       # Mypy should infer this as UUID | None
       uuid_val: Optional[UUID] = Dashboard().uuid
       reveal_type(Dashboard().uuid)
   ```


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org