MaartenGr / MaartenGr/KeyBERT

Argument of type "None" cannot be assigned to parameter "stop_words" of type "str | List[str]" in function "extract_keywords"

Open
#265 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
4.2k
Forks
385
PR merge metrics
No merged PRs in 30d

Description

Small warning between the documentation and the code implementation (nothing serious)

With the bellow code I have a warning:
Argument of type "None" cannot be assigned to parameter "stop_words" of type "str | List[str]" in function "extract_keywords"
Type "None" is not assignable to type "str | List[str]"
"None" is not assignable to "str"
"None" is not assignable to "List[str]"
```python
sim = kw_model.extract_keywords(text,
keyphrase_ngram_range=(1, 1),
stop_words=None,
vectorizer=vectorizer,
top_n=list_words.__len__())
```

I'm not sure this is intended, as in the following example in the documentation, stop_words is None.
```python
>>> kw_model.extract_keywords(doc, keyphrase_ngram_range=(1, 1), stop_words=None)
[('learning', 0.4604),
('algorithm', 0.4556),
('training', 0.4487),
('class', 0.4086),
('mapping', 0.3700)]
```

So should the documentation or code be changed?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the extract_keywords entry point and compare the stop_words type accepted by the implementation with the documentation example that passes None. Check the relevant typing or documentation source, then update the inconsistent part and verify that the warning and example agree.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.