README usage example raises `NameError: name 'subscription_info' is not defined`

Abierto Apto para principiantes
#216 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Busca el ejemplo de uso en el README y el ejemplo correspondiente en la página de PyPI. Define un objeto subscription_info representativo y los datos antes de llamar a webpush, siguiendo la estructura mostrada en el issue. Confirma que el ejemplo ya no genera NameError y muestra el paso esperado de credenciales y solicitud.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

The usage example in the README (and the PyPI page) is:

from pywebpush import webpush

webpush(subscription_info,
        data,
        vapid_private_key="Private Key or File Path[1]",
        vapid_claims={"sub": "mailto:YourEmailAddress"})

Copied verbatim into a clean environment it dies immediately, because neither subscription_info nor data is ever defined:

$ pip install pywebpush   # 2.5.0
$ python sample.py
NameError: name 'subscription_info' is not defined

Reproduced 2026-11-21 and re-verified 2026-11-25 (pywebpush 2.5.0, Python 3.12.3). A new user can't tell what shape subscription_info is supposed to have, so the example stops them before the VAPID step it is trying to teach.

Suggested fix — show concrete literals, e.g.:

subscription_info = {
    "endpoint": "https://push.example.com/...",
    "keys": {"p256dh": "...", "auth": "..."},
}
data = "hello from pywebpush"

webpush(subscription_info,
        data,
        vapid_private_key="path/to/private_key.pem",
        vapid_claims={"sub": "mailto:[email protected]"})

That runs through to the actual credential/request step, which is where a first-time user expects to spend their effort.


Found while running the documented quickstarts of 50 APIs from clean environments for a small benchmark (the Quickstart Friction Index — full data and a free sample: https://neoloong.gumroad.com/l/bxpkri). Happy to re-run and confirm once fixed.

Lenguaje dominante
Python
Estrellas
381
Forks
61
Merge medio
6 min
PR fusionados (30 d)
1

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de web-push-libs/pywebpush

Todos los issues de web-push-libs/pywebpush

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.