posit-dev / posit-dev/py-shiny
Should check that generated stubs have type annotations
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
When creating type stubs with stubgen and pyright, members which aren't explicitly annotated generally don't get a type annontation.
For example, when generating stubs with stubgen -p shiny, the resulting _shinyenv.pyi file had the following:
from _typeshed import Incomplete
is_pyodide: Incomplete
With pyright --create-stubs shiny, the result is similar:
is_pyodide = ...
The same thing happens when class instance members are defined within the init method. For example, suppose a class has something like this:
class Test:
def __init__(x: int):
self.x = x
``
When `stubgen` generates the stub, it loses the type for `x`:
```py
from _typeshed import Incomplete
class Test:
x: Incomplete
def __init__(x: int) -> None: ...
When pyright generates the stub, it loses information about x completely. The result is:
class Test:
def __init__() -> None:
...
This was partially addressed in 57c39b771b32322c8c833a47339bb644f67a2261.
I think the best way to go about checking for this is to use stubgen in CI and search for any instances of Incomplete.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the stubgen and pyright entry points described in the issue, generating stubs for the shiny package and inspecting the resulting .pyi files. Check how CI currently runs and how generated output can be searched for Incomplete or missing member types. Done means CI reliably detects the annotation loss described for module members and instance members.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ci-cd, developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100