Skip to content

Conversation

@seriaati
Copy link
Contributor

@seriaati seriaati commented Jan 12, 2026

Description

This PR adds covariant=True to the TypeVar definition in Ref.

This is added because otherwise pyright will raise error, example:

Argument of type "Ref[TextField]" cannot be assigned to parameter "ref" of type "Ref[BaseControl] | None" in function "__init__"
  Type "Ref[TextField]" is not assignable to type "Ref[BaseControl] | None"
    "Ref[TextField]" is not assignable to "Ref[BaseControl]"
      Type parameter "T@Ref" is invariant, but "TextField" is not the same as "BaseControl"
    "Ref[TextField]" is not assignable to "None"

Test Code

import flet as ft

ref = ft.Ref[ft.TextField]()
text_field = ft.TextField(ref=ref)
pyright .

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

Screenshots

Additional details

Summary by Sourcery

Bug Fixes:

  • Fix type checking errors by marking the Ref generic type parameter as covariant.

@CLAassistant
Copy link

CLAassistant commented Jan 12, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@FeodorFitsner FeodorFitsner merged commit 6b98f59 into flet-dev:main Jan 12, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants