Stubgen creates instance methods instead of class variables for C extensions
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug Report
We are in the process of adding .pyi stubs for PyICU. (https://gitlab.pyicu.org/)
The URegionType class, for example, is an enumeration. inspect.getmembers(icu.URegionType) lists [('CONTINENT', 3), ('DEPRECATED', 6), ('GROUPING', 5), ('SUBCONTINENT', 4), ('TERRITORY', 1), ('UNKNOWN', 0), ('WORLD', 2), ('__class__', <class 'type'>), ('__delattr__', <slot wrapper '__delattr__' of 'object' objects>), ...
CONTINENT and other class variables are generated in _icu_.pyi as if they were class methods.
To Reproduce
The problem might be specific to C extensions. If you want to recreate the problem on the PyICU code:
python setup.py build
cd build/lib.linux-x86_64-cpython-310
stubgen -p icu
Expected Behavior
_icu_.pyi should have contained
class URegionType:
CONTINENT: Any
DEPRECATED: Any
GROUPING: Any
SUBCONTINENT: Any
TERRITORY: Any
UNKNOWN: Any
WORLD: Any
Actual Behavior
_icu_.pyi instead contains:
class URegionType:
def CONTINENT(self, *args, **kwargs) -> Any: ...
def DEPRECATED(self, *args, **kwargs) -> Any: ...
def GROUPING(self, *args, **kwargs) -> Any: ...
def SUBCONTINENT(self, *args, **kwargs) -> Any: ...
def TERRITORY(self, *args, **kwargs) -> Any: ...
def UNKNOWN(self, *args, **kwargs) -> Any: ...
def WORLD(self, *args, **kwargs) -> Any: ...
Your Environment
- Mypy version used: 0.990
- Mypy configuration options from
mypy.ini(and other config files): defaults/none - Python version used: 3.10
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il problema con i comandi di build PyICU forniti e ispeziona il percorso stubgen che classifica i membri delle estensioni C. Conferma l’output icu.pyi generato per URegionType, quindi aggiungi coverage o una correzione in modo che CONTINENT e gli altri membri dell’enumerazione vengano emessi come variabili di classe anziché come metodi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100