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

Annotate Widget params as Any #7132

Merged
merged 1 commit into from
Aug 12, 2024
Merged

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

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.

@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
12 of 16 checks passed
@gandhis1 gandhis1 deleted the widget_init branch August 12, 2024 11:47
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.

2 participants