polm / fugashi

A Cython MeCab wrapper for fast, pythonic Japanese tokenization and morphological analysis.
MIT License
402 stars 33 forks source link

Pylance linting gives error: "Tagger" is not a known member of module "fugashi" #85

Closed roblframpton closed 1 year ago

roblframpton commented 1 year ago

I am using fugshi in a Python project. I created a venv, and then did the following:

pip install fugashi[unidic-lite]

I created a file called analyze/analyze_jp.py:

import fugashi

tagger = fugashi.Tagger("-Odump")

Executing this script works fine, but the Pylance linter in VSCode gives an error saying '"Tagger" is not a known member of module "fugashi"'.

image

All my other packages are fine. Is there a reason this happens in fugashi?

polm commented 1 year ago

This probably happens because fugashi uses C extensions, via Cython. That means classes in fugashi are not normal Python code. I have heard of similar issues with other package that use C extensions in other IDEs.

Based on https://github.com/microsoft/pylance-release/issues/2440, it looks like this could probably be fixed by adding type stubs to fugashi. I have no interest in adding type stubs myself, but if someone made a PR with them and it could be maintained with minimal effort I would take a look at it.

polm commented 1 year ago

Going to close this since I'm not going to work on it and it's not a bug.