Skip to content

Commit

Permalink
fix: typing annotation for set python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTheFactory committed Nov 8, 2023
1 parent 592f6f6 commit 895343f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions newspaper/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import glob
from pathlib import Path
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Set
from urllib.parse import urlparse
import lxml

Expand Down Expand Up @@ -98,7 +98,7 @@ class Article:
the first config.MAX_KEYWORDS keywords.
meta_keywords (List[str]): A list of keywords provided by the meta data.
It will be truncated to the first config.MAX_KEYWORDS keywords.
tags (set[str]): Extracted tag list from the article body
tags (Set[str]): Extracted tag list from the article body
authors (List[str]): The author list parsed from the article. It will
be truncated to the first config.MAX_AUTHORS authors.
publish_date (str): The parsed publishing date from the article. If no
Expand Down Expand Up @@ -233,7 +233,7 @@ def __init__(
self.meta_keywords: List[str] = []

# `tags` are also extracted via parse() from <meta> tags
self.tags: set[str] = set()
self.tags: Set[str] = set()

# List of authors who have published the article, via parse()
self.authors: List[str] = []
Expand Down
4 changes: 2 additions & 2 deletions newspaper/extractors/metadata_extractor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import Any, Dict, Optional
from typing import Any, Dict, Optional, Set
from urllib.parse import urlparse, urlunparse

import lxml
Expand Down Expand Up @@ -165,7 +165,7 @@ def _get_metadata(self, doc: lxml.html.Element) -> Dict[str, Any]:
ref = ref[part]
return data

def _get_tags(self, doc: lxml.html.Element) -> set[str]:
def _get_tags(self, doc: lxml.html.Element) -> Set[str]:
"""Extracts tags from the article's HTML"""

elements = self.parser.css_select(
Expand Down
4 changes: 2 additions & 2 deletions newspaper/nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import math
from pathlib import Path
from collections import Counter
from typing import List
from typing import List, Set

from . import settings

stopwords: set[str] = set()
stopwords: Set[str] = set()


def load_stopwords(language):
Expand Down

0 comments on commit 895343f

Please sign in to comment.