8000 Annotate Widget params as Any by gandhis1 · Pull Request #7132 · holoviz/panel · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@gandhis1
Copy link
Contributor
@gandhis1 gandhis1 commented Aug 11, 2024

Part of #7078

Users who run their own code in Mypy strict mode require that all calls they make are to typed interfaces.

I did initially explore the possibility of annotating these **params as Unpack[TypedDict] (see PEP 692) but it was not readily apparent from the source code what all the possibilities were, and until PEP 728 is accepted this had the potential to break perfectly valid code that were using parameters that I did not anticipate. So I dropped this idea pretty quickly.

But to solve the basic issue in user code, all this needs is an annotation - of any kind. So I went ahead and added an Any.

Here is some sample code, run on Mypy strict:

from panel.widgets.input import StaticText

t1 = StaticText()

Before:

>> mypy panel_test_code.py --follow-imports=silent --strict
panel_test_code.py:3: error: Call to untyped function "StaticText" in typed context  [no-untyped-call]

After:

>> mypy panel_test_code.py --follow-imports=silent --strict
Success: no issues found in 1 source file

@MarcSkovMadsen

@codecov
Copy link
codecov bot commented Aug 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.38%. Comparing base (2a53e2a) to head (00747c4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7132      +/-   ##
==========================================
- Coverage   72.39%   72.38%   -0.01%     
==========================================
  Files         326      326              
  Lines       48827    48827              
==========================================
- Hits        35347    35343       -4     
- Misses      13480    13484       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

8000
@philippjfr
Copy link
Member

Test failures are unrelated and are resolved elsewhere. I'm okay with this change for now. Adding typing for param is definitely on our to-do list but is definitely a very complex project.

@philippjfr philippjfr merged commit 93b43a6 into holoviz:main Aug 12, 2024
@gandhis1 gandhis1 deleted the widget_init branch August 12, 2024 11:47
@github-actions
Copy link
github-actions bot commented Sep 9, 2025

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0