holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.78k stars 518 forks source link

Incomplete/missing type annotations #7078

Open gandhis1 opened 3 months ago

gandhis1 commented 3 months ago

A number of elements of the public interface are untyped and thus can get flagged in user code that uses strict typing. Here are just a few. I'm flagging these as it's not clear whether this is intentional - large parts of panel are annotated and these seem to just have been missed more so than a deliberate choice to not type them.

error: Untyped decorator makes function X untyped  [misc] (this was for @pn.cache)
error: Untyped decorator makes function X untyped  [misc] (this was for @pn.io.profile)
error: Call to untyped function "Button" in typed context  [no-untyped-call] (pn.widgets.Button)
error: Call to untyped function X in typed context  [no-untyped-call] (inherits from pn.widgets.Tabulator)
error: Call to untyped function "StaticText" in typed context  [no-untyped-call] (pn.widgets.StaticText)
error: Call to untyped function "Card" in typed context  [no-untyped-call] (pn.Card)
error: Call to untyped function "HSpacer" in typed context  [no-untyped-call] (pn.layout.HSpacer)
error: Call to untyped function "Number" in typed context  [no-untyped-call] (pn.indicators.Number)
error: Call to untyped function X in typed context  [no-untyped-call] (inherits from pn.viewable.Viewer)

In particular, annotations appear to be missing from a bunch of __init__ - even an Any would be better than nothing.

I've annotated tons of code in the past, including on several major OSS code bases, so happy to help out if there is interest.

MarcSkovMadsen commented 3 months ago

Help would be awesome. Type annotations makes Panel much easier to use for users.

I would recommend you try to make a smaller contribution as a start. See how its received and if anything needs to be aligned/ discussed. Then do one or more larger PRs.

I would like to be a reviewer.