Skip to content

Commit 411eadd

Browse files
chores: py support; GHA; pyproject.toml; dev env updates; license yr; pytest; etc (#426)
* chores: pyproject.toml; ruff; license yr; pytest; etc * tox -e lint * Fix fork button; remove mentions of Python 2 * Remove translate module and methods * Remove compat module * minor docs updates * remove unused coverage config * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update readme * Remove unused ignores * Update contributing * Remove unnecessary mock dep * add readthedocs config --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9945064 commit 411eadd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3853
-3317
lines changed

.coveragerc

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: pip
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"

.github/workflows/build-release.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: build
2+
on:
3+
push:
4+
branches: ["dev"]
5+
tags: ["*"]
6+
pull_request:
7+
8+
jobs:
9+
tests:
10+
name: ${{ matrix.name }}
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- { name: "3.8", python: "3.8", tox: py38 }
17+
- { name: "3.12", python: "3.12", tox: py312 }
18+
- { name: "lowest", python: "3.8", tox: py38-lowest }
19+
steps:
20+
- uses: actions/[email protected]
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python }}
24+
- name: Download nltk data
25+
run: wget https://s3.amazonaws.com/textblob/nltk_data-0.11.0.tar.gz
26+
- name: Extract nltk data
27+
run: tar -xzvf nltk_data-0.11.0.tar.gz -C ~
28+
- run: python -m pip install tox
29+
- run: python -m tox -e${{ matrix.tox }}
30+
build:
31+
name: Build package
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: actions/setup-python@v5
36+
with:
37+
python-version: "3.11"
38+
- name: Install pypa/build
39+
run: python -m pip install build
40+
- name: Build a binary wheel and a source tarball
41+
run: python -m build
42+
- name: Install twine
43+
run: python -m pip install twine
44+
- name: Check build
45+
run: python -m twine check --strict dist/*
46+
- name: Store the distribution packages
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: python-package-distributions
50+
path: dist/
51+
# this duplicates pre-commit.ci, so only run it on tags
52+
# it guarantees that linting is passing prior to a release
53+
lint-pre-release:
54+
if: startsWith(github.ref, 'refs/tags')
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/[email protected]
58+
- uses: actions/setup-python@v5
59+
with:
60+
python-version: "3.11"
61+
- run: python -m pip install tox
62+
- run: python -m tox -e lint
63+
publish-to-pypi:
64+
name: PyPI release
65+
if: startsWith(github.ref, 'refs/tags/')
66+
needs: [build, tests, lint-pre-release]
67+
runs-on: ubuntu-latest
68+
environment:
69+
name: pypi
70+
url: https://pypi.org/p/textblob
71+
permissions:
72+
id-token: write
73+
steps:
74+
- name: Download all the dists
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: python-package-distributions
78+
path: dist/
79+
- name: Publish distribution to PyPI
80+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
### Python ###
2-
31
*.py[cod]
42

3+
# virtualenv
4+
.venv/
5+
venv/
6+
57
# C extensions
68
*.so
79

@@ -19,16 +21,17 @@ develop-eggs
1921
.installed.cfg
2022
lib
2123
lib64
22-
__pycache__
23-
cover
2424

25-
# Installer logs
25+
# pip
2626
pip-log.txt
27+
pip-wheel-metadata
2728

2829
# Unit test / coverage reports
2930
.coverage
3031
.tox
3132
nosetests.xml
33+
test-output/
34+
.pytest_cache
3235

3336
# Translations
3437
*.mo
@@ -38,22 +41,19 @@ nosetests.xml
3841
.project
3942
.pydevproject
4043

41-
*.bak
42-
.bumpversion.cfg
44+
# Complexity
45+
output/*.html
46+
output/*/index.html
4347

44-
# Docs
48+
# Sphinx
4549
docs/_build
50+
README.html
4651

47-
# Pylint
48-
pylintrc
49-
50-
### Extra models and data ###
52+
# mypy
5153

52-
text/*.pickle
53-
text/en/*.pickle
54+
.mypy_cache
5455

55-
# Readme build
56-
README.html
56+
!tests/.env
5757

58-
.ipynb_checkpoints/
59-
*.ipynb
58+
# ruff
59+
.ruff_cache

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.2.1
4+
hooks:
5+
- id: ruff
6+
- id: ruff-format
7+
- repo: https://github.com/python-jsonschema/check-jsonschema
8+
rev: 0.28.0
9+
hooks:
10+
- id: check-github-workflows
11+
- repo: https://github.com/asottile/blacken-docs
12+
rev: 1.16.0
13+
hooks:
14+
- id: blacken-docs
15+
additional_dependencies: [black==23.12.1]

.readthedocs.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
sphinx:
3+
configuration: docs/conf.py
4+
formats:
5+
- pdf
6+
build:
7+
os: ubuntu-22.04
8+
tools:
9+
python: "3.11"
10+
python:
11+
install:
12+
- method: pip
13+
path: .
14+
extra_requirements:
15+
- docs

.travis.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

CHANGELOG.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Changelog
22
=========
33

4+
0.18.0 (unreleased)
5+
-------------------
6+
7+
Removals:
8+
9+
- ``TextBlob.translate()`` and ``TextBlob.detect_language``, and ``textblob.translate``
10+
are removed. Use the official Google Translate API instead (:issue:`215`).
11+
- Remove ``textblob.compat``.
12+
13+
Support:
14+
15+
- Support Python 3.8-3.12. Older versions are no longer supported.
16+
- Support nltk>=3.8.
17+
418
0.17.1 (2021-10-21)
519
-------------------
620

CONTRIBUTING.rst

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ To create a new extension for a part-of-speech tagger, sentiment analyzer, noun
5757
5858
from textblob.base import BaseTagger
5959
60+
6061
class MyTagger(BaseTagger):
6162
def tag(self, text):
63+
pass
6264
# Your implementation goes here
6365
6466
Language Extensions
@@ -102,7 +104,6 @@ Pull Requests
102104

103105
- If the pull request adds functionality, it is tested and the docs are updated.
104106
- If you've developed an extension, it is on the :ref:`Extensions List <extensions>`.
105-
- The pull request works on Python 2.7, 3.4, 3.5, 3.6, and PyPy. Use ``tox`` to verify that it does.
106107
- You've added yourself to ``AUTHORS.rst``.
107108

108109
4. Submit a pull request to the ``sloria:dev`` branch.
@@ -112,34 +113,20 @@ Running tests
112113

113114
To run all the tests: ::
114115

115-
$ python run_tests.py
116+
$ pytest
116117

117118
To skip slow tests: ::
118119

119-
$ python run_tests.py fast
120-
121-
To skip tests that require internet: ::
122-
123-
$ python run_tests.py no-internet
124-
125-
To get test coverage reports (must have coverage installed): ::
126-
127-
$ python run_tests.py cover
128-
129-
To run tests on Python 2.7, 3.4, 3.5, and 3.6 virtual environments (must have each interpreter installed): ::
130-
131-
$ tox
120+
$ pytest -m 'not slow'
132121

133122
Documentation
134123
+++++++++++++
135124

136125
Contributions to the documentation are welcome. Documentation is written in `reStructuredText`_ (rST). A quick rST reference can be found `here <https://docutils.sourceforge.io/docs/user/rst/quickref.html>`_. Builds are powered by Sphinx_.
137126

138-
To build docs: ::
139-
140-
$ invoke docs -b
127+
To build docs and run in watch mode: ::
141128

142-
The ``-b`` (for "browse") automatically opens up the docs in your browser after building.
129+
$ tox -e watch-docs
143130

144131
.. _Sphinx: http://sphinx.pocoo.org/
145132

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2013-2021 Steven Loria
1+
Copyright Steven Loria and contributors
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

MANIFEST.in

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.rst

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ TextBlob: Simplified Text Processing
66
:target: https://pypi.org/project/textblob/
77
:alt: Latest version
88

9-
.. image:: https://badgen.net/travis/sloria/TextBlob/dev
10-
:target: https://travis-ci.org/sloria/TextBlob
11-
:alt: Travis-CI
9+
.. image:: https://github.com/sloria/TextBlob/actions/workflows/build-release.yml/badge.svg
10+
:target: https://github.com/sloria/TextBlob/actions/workflows/build-release.yml
11+
:alt: Build status
12+
1213

1314
Homepage: `https://textblob.readthedocs.io/ <https://textblob.readthedocs.io/>`_
1415

15-
`TextBlob` is a Python (2 and 3) library for processing textual data. It provides a simple API for diving into common natural language processing (NLP) tasks such as part-of-speech tagging, noun phrase extraction, sentiment analysis, classification, translation, and more.
16+
`TextBlob` is a Python library for processing textual data. It provides a simple API for diving into common natural language processing (NLP) tasks such as part-of-speech tagging, noun phrase extraction, sentiment analysis, classification, translation, and more.
1617

1718

1819
.. code-block:: python
1920
2021
from textblob import TextBlob
2122
22-
text = '''
23+
text = """
2324
The titular threat of The Blob has always struck me as the ultimate movie
2425
monster: an insatiably hungry, amoeba-like mass able to penetrate
2526
virtually any safeguard, capable of--as a doomed doctor chillingly
@@ -28,15 +29,15 @@ Homepage: `https://textblob.readthedocs.io/ <https://textblob.readthedocs.io/>`_
2829
devastating of potential consequences, not unlike the grey goo scenario
2930
proposed by technological theorists fearful of
3031
artificial intelligence run rampant.
31-
'''
32+
"""
3233
3334
blob = TextBlob(text)
34-
blob.tags # [('The', 'DT'), ('titular', 'JJ'),
35-
# ('threat', 'NN'), ('of', 'IN'), ...]
35+
blob.tags # [('The', 'DT'), ('titular', 'JJ'),
36+
# ('threat', 'NN'), ('of', 'IN'), ...]
3637
37-
blob.noun_phrases # WordList(['titular threat', 'blob',
38-
# 'ultimate movie monster',
39-
# 'amoeba-like mass', ...])
38+
blob.noun_phrases # WordList(['titular threat', 'blob',
39+
# 'ultimate movie monster',
40+
# 'amoeba-like mass', ...])
4041
4142
for sentence in blob.sentences:
4243
print(sentence.sentiment.polarity)
@@ -82,11 +83,6 @@ Documentation
8283

8384
Full documentation is available at https://textblob.readthedocs.io/.
8485

85-
Requirements
86-
------------
87-
88-
- Python >= 2.7 or >= 3.5
89-
9086
Project Links
9187
-------------
9288

0 commit comments

Comments
 (0)