Skip to content

Commit

Permalink
Basic mypy support (#613)
Browse files Browse the repository at this point in the history
* Documentation changes v0.9.2 (#610)

* Documentation changes v0.9.2 (#604) (#605)

* feat(doc): 📝 adding evaluation results

* feat(doc): 🚀 Documentation Update. Added Examples, documented new features

* feat: Basic mypy support

* Explicitly define ArticleBodyTag to remove score_boost check

* Simplify favicon return

* Add overload to to_json to specify types

---------

Co-authored-by: Andrei Paraschiv <andrei@thephpfactory.com>
  • Loading branch information
palfrey and AndyTheFactory authored Feb 26, 2024
1 parent 44f92f9 commit 25ab806
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs: # jobs. We will have two jobs (test and publish) with multiple steps.
run: |
python -m pip install --upgrade pip
poetry config virtualenvs.create false --local
poetry install --all-extras
pip install pytest pylint coverage mypy coveralls
# python -m nltk.downloader punkt stopwords
Expand Down
1 change: 1 addition & 0 deletions newspaper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
logging.getLogger(__name__).addHandler(NullHandler())



def article(url: str, language: Optional[str] = None, **kwargs) -> Article:
"""Shortcut function to fetch and parse a newspaper article from a URL.
Expand Down
4 changes: 2 additions & 2 deletions newspaper/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def is_binary_url(url: str) -> bool:
chars = len(
[
char
for char in content
if 31 < ord(char) < 128 or ord(char) in [9, 10, 13]
for char in [ord(c) if isinstance(c, str) else c for c in content]
if 31 < char < 128 or char in [9, 10, 13]
]
)
if chars / len(content) < 0.6: # 40% of the content is binary
Expand Down
73 changes: 72 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 25ab806

Please sign in to comment.