Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oleksis/6ba0a55733f9373af3ecc2843d2993dc to your computer and use it in GitHub Desktop.
Save oleksis/6ba0a55733f9373af3ecc2843d2993dc to your computer and use it in GitHub Desktop.
Generar archivos stubs (.pyi) usando mypy

Generar archivos stubs (.pyi) usando mypy

spaCy es un paquete para el Procesamiento avanzado del Lenguaje Natural (NLP) en Python y Cython.

Algunos módulos de spaCy entan escrito en Cython. Si queremos usar chequeo de Type Hints y generar los archivos .pyi , usaremos la herramienta stubgen de mypy para generar los stubs.

Usando Powershell

pip install -U mypy
$GET_SPACY_PATH='python -c "from pathlib import Path ; import spacy ; print(Path(spacy.__file__).parent.absolute())"'
Set-Variable -Name "SPACY_DIR" -Value (Invoke-Expression($GET_SPACY_PATH))
stubgen -o typings $SPACY_DIR

Usando Bash

pip install -U mypy
SPACY_DIR=$(python -c "from pathlib import Path ; import spacy ; print(Path(spacy.__file__).parent.absolute())")
stubgen -o typings $SPACY_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment