Skip to content

Commit

Permalink
chores: py support; GHA; pyproject.toml; dev env updates; license yr;…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
sloria and pre-commit-ci[bot] authored Feb 15, 2024
1 parent 9945064 commit 411eadd
Show file tree
Hide file tree
Showing 80 changed files with 3,853 additions and 3,317 deletions.
14 changes: 0 additions & 14 deletions .coveragerc

This file was deleted.

11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
80 changes: 80 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: build
on:
push:
branches: ["dev"]
tags: ["*"]
pull_request:

jobs:
tests:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { name: "3.8", python: "3.8", tox: py38 }
- { name: "3.12", python: "3.12", tox: py312 }
- { name: "lowest", python: "3.8", tox: py38-lowest }
steps:
- uses: actions/[email protected]
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Download nltk data
run: wget https://s3.amazonaws.com/textblob/nltk_data-0.11.0.tar.gz
- name: Extract nltk data
run: tar -xzvf nltk_data-0.11.0.tar.gz -C ~
- run: python -m pip install tox
- run: python -m tox -e${{ matrix.tox }}
build:
name: Build package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install pypa/build
run: python -m pip install build
- name: Build a binary wheel and a source tarball
run: python -m build
- name: Install twine
run: python -m pip install twine
- name: Check build
run: python -m twine check --strict dist/*
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
# this duplicates pre-commit.ci, so only run it on tags
# it guarantees that linting is passing prior to a release
lint-pre-release:
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: python -m pip install tox
- run: python -m tox -e lint
publish-to-pypi:
name: PyPI release
if: startsWith(github.ref, 'refs/tags/')
needs: [build, tests, lint-pre-release]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/textblob
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
36 changes: 18 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
### Python ###

*.py[cod]

# virtualenv
.venv/
venv/

# C extensions
*.so

Expand All @@ -19,16 +21,17 @@ develop-eggs
.installed.cfg
lib
lib64
__pycache__
cover

# Installer logs
# pip
pip-log.txt
pip-wheel-metadata

# Unit test / coverage reports
.coverage
.tox
nosetests.xml
test-output/
.pytest_cache

# Translations
*.mo
Expand All @@ -38,22 +41,19 @@ nosetests.xml
.project
.pydevproject

*.bak
.bumpversion.cfg
# Complexity
output/*.html
output/*/index.html

# Docs
# Sphinx
docs/_build
README.html

# Pylint
pylintrc

### Extra models and data ###
# mypy

text/*.pickle
text/en/*.pickle
.mypy_cache

# Readme build
README.html
!tests/.env

.ipynb_checkpoints/
*.ipynb
# ruff
.ruff_cache
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.0
hooks:
- id: check-github-workflows
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.12.1]
15 changes: 15 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
sphinx:
configuration: docs/conf.py
formats:
- pdf
build:
os: ubuntu-22.04
tools:
python: "3.11"
python:
install:
- method: pip
path: .
extra_requirements:
- docs
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
Changelog
=========

0.18.0 (unreleased)
-------------------

Removals:

- ``TextBlob.translate()`` and ``TextBlob.detect_language``, and ``textblob.translate``
are removed. Use the official Google Translate API instead (:issue:`215`).
- Remove ``textblob.compat``.

Support:

- Support Python 3.8-3.12. Older versions are no longer supported.
- Support nltk>=3.8.

0.17.1 (2021-10-21)
-------------------

Expand Down
25 changes: 6 additions & 19 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ To create a new extension for a part-of-speech tagger, sentiment analyzer, noun
from textblob.base import BaseTagger
class MyTagger(BaseTagger):
def tag(self, text):
pass
# Your implementation goes here
Language Extensions
Expand Down Expand Up @@ -102,7 +104,6 @@ Pull Requests

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

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

To run all the tests: ::

$ python run_tests.py
$ pytest

To skip slow tests: ::

$ python run_tests.py fast

To skip tests that require internet: ::

$ python run_tests.py no-internet

To get test coverage reports (must have coverage installed): ::

$ python run_tests.py cover

To run tests on Python 2.7, 3.4, 3.5, and 3.6 virtual environments (must have each interpreter installed): ::

$ tox
$ pytest -m 'not slow'

Documentation
+++++++++++++

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_.

To build docs: ::

$ invoke docs -b
To build docs and run in watch mode: ::

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

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

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2013-2021 Steven Loria
Copyright Steven Loria and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

28 changes: 12 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ TextBlob: Simplified Text Processing
:target: https://pypi.org/project/textblob/
:alt: Latest version

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


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

`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.
`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.


.. code-block:: python
from textblob import TextBlob
text = '''
text = """
The titular threat of The Blob has always struck me as the ultimate movie
monster: an insatiably hungry, amoeba-like mass able to penetrate
virtually any safeguard, capable of--as a doomed doctor chillingly
Expand All @@ -28,15 +29,15 @@ Homepage: `https://textblob.readthedocs.io/ <https://textblob.readthedocs.io/>`_
devastating of potential consequences, not unlike the grey goo scenario
proposed by technological theorists fearful of
artificial intelligence run rampant.
'''
"""
blob = TextBlob(text)
blob.tags # [('The', 'DT'), ('titular', 'JJ'),
# ('threat', 'NN'), ('of', 'IN'), ...]
blob.tags # [('The', 'DT'), ('titular', 'JJ'),
# ('threat', 'NN'), ('of', 'IN'), ...]
blob.noun_phrases # WordList(['titular threat', 'blob',
# 'ultimate movie monster',
# 'amoeba-like mass', ...])
blob.noun_phrases # WordList(['titular threat', 'blob',
# 'ultimate movie monster',
# 'amoeba-like mass', ...])
for sentence in blob.sentences:
print(sentence.sentiment.polarity)
Expand Down Expand Up @@ -82,11 +83,6 @@ Documentation

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

Requirements
------------

- Python >= 2.7 or >= 3.5

Project Links
-------------

Expand Down
Loading

0 comments on commit 411eadd

Please sign in to comment.