Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 BUG] Mismatch between bound variable type and Pylance #2430

Open
1 of 7 tasks
HoseynAAmiri opened this issue Jan 28, 2025 · 1 comment
Open
1 of 7 tasks

[🐛 BUG] Mismatch between bound variable type and Pylance #2430

HoseynAAmiri opened this issue Jan 28, 2025 · 1 comment
Labels
🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟨 Priority: Medium Not blocking but should be addressed

Comments

@HoseynAAmiri
Copy link

HoseynAAmiri commented Jan 28, 2025

What went wrong? 🤔

There is a type checking error from Pylance as I use binding:

tgb.selector(
    value="{selected_subcategory}",
    lov="{subcategories}",
    dropdown=True,
)

Argument of type "Literal['{subcategories}']" cannot be assigned to parameter "lov" of type "dict[str, Any] | None" in function "init"
Type "Literal['{subcategories}']" is not assignable to type "dict[str, Any] | None"
"Literal['{subcategories}']" is not assignable to "dict[str, Any]"
"Literal['{subcategories}']" is not assignable to "None"

And even without binding something like:

tgb.selector(
    value="{selected_subcategory}",
    lov=['x', 'y', 'z'],
    dropdown=True,
)

Argument of type "list[str]" cannot be assigned to parameter "lov" of type "dict[str, Any] | None" in function "init"
Type "list[str]" is not assignable to type "dict[str, Any] | None"
"list[str]" is not assignable to "dict[str, Any]"
"list[str]" is not assignable to "None"

So, it only accepts an lov type of dict[str, Any] that does not even work!

Additional Context

Acceptance Criteria

  • A unit test reproducing the bug is added.
  • Any new code is covered by a unit tested.
  • Check code coverage is at least 90%.
  • The bug reporter validated the fix.
  • Related issue(s) in taipy-doc are created for documentation and Release Notes are updated.

Code of Conduct

  • I have checked the existing issues.
  • I am willing to work on this issue (optional)
@HoseynAAmiri HoseynAAmiri added the 💥Malfunction Addresses an identified problem. label Jan 28, 2025
@FlorianJacta
Copy link
Member

FlorianJacta commented Jan 29, 2025

Thank you; this issue is interesting as Taipy uses different ways to bind variables. The nature of the bound variable can be different from what Pylance sees. In your example, you pass a list of string (as a bound variable) but Pylance sees a string. The second use case is another issue that could be quickly solved

@FlorianJacta FlorianJacta added 🖰 GUI Related to GUI 🟨 Priority: Medium Not blocking but should be addressed labels Jan 29, 2025
@FlorianJacta FlorianJacta changed the title [🐛 BUG] <write a small description here> [🐛 BUG] Mismatch between bound variable type and Pylance Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟨 Priority: Medium Not blocking but should be addressed
Projects
None yet
Development

No branches or pull requests

2 participants