Skip to content

Commit 51725c7

Browse files
authored
Create GitHub Action to run codespell and ruff (#82)
* Create GitHub Action to run codespell and ruff * .github/workflows/codespell_and_ruff.yml * Update codespell_and_ruff.yml * changelog.rst: Fix typos discovered by codespell * tasks.py: Fix typos discovered by codespell * utils.py: Fix typos discovered by codespell * Create .pre-commit-config.yaml * conf.py: Comment out unused imports * noqa: E731 * ruff --format=github --target-version=py38 . * noqa: E731
1 parent d27398d commit 51725c7

File tree

6 files changed

+59
-14
lines changed

6 files changed

+59
-14
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This Action uses minimal steps to run in ~5 seconds to rapidly:
2+
# find typos in the codebase using codespell, and
3+
# lint Python code using ruff and provide intuitive GitHub Annotations to contributors.
4+
# https://github.com/codespell-project/codespell#readme
5+
# https://beta.ruff.rs
6+
name: codespell_and_ruff
7+
on:
8+
push:
9+
branches: [develop]
10+
pull_request:
11+
branches: [develop]
12+
jobs:
13+
ruff:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- run: pip install --user codespell[toml] ruff
18+
- run: codespell # --ignore-words-list="" --skip="*.css,*.js,*.lock,*.po"
19+
- run: ruff --format=github --target-version=py38 .

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# To enable this pre-commit hook run:
2+
# `pip install pre-commit` or `brew install pre-commit`
3+
# Then run `pre-commit install`
4+
5+
# Learn more about this config here: https://pre-commit.com/
6+
default_language_version:
7+
python: python3.11
8+
9+
ci:
10+
submodules: true
11+
12+
repos:
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
rev: v0.0.278
15+
hooks:
16+
- id: ruff # See pyproject.toml for args
17+
18+
- repo: https://github.com/codespell-project/codespell
19+
rev: v2.2.5
20+
hooks:
21+
- id: codespell # See pyproject.toml for args
22+
additional_dependencies:
23+
- tomli

celery_haystack/tasks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def split_identifier(self, identifier, **kwargs):
2828

2929
if len(bits) < 2:
3030
logger.error("Unable to parse object "
31-
"identifer '%s'. Moving on..." % identifier)
31+
"identifier '%s'. Moving on..." % identifier)
3232
return (None, None)
3333

3434
pk = bits[-1]
@@ -38,7 +38,7 @@ def split_identifier(self, identifier, **kwargs):
3838

3939
def get_model_class(self, object_path, **kwargs):
4040
"""
41-
Fetch the model's class in a standarized way.
41+
Fetch the model's class in a standardized way.
4242
"""
4343
bits = object_path.split('.')
4444
app_name = '.'.join(bits[:-1])
@@ -52,7 +52,7 @@ def get_model_class(self, object_path, **kwargs):
5252

5353
def get_instance(self, model_class, pk, **kwargs):
5454
"""
55-
Fetch the instance in a standarized way.
55+
Fetch the instance in a standardized way.
5656
"""
5757
instance = None
5858
try:
@@ -67,7 +67,7 @@ def get_instance(self, model_class, pk, **kwargs):
6767

6868
def get_indexes(self, model_class, **kwargs):
6969
"""
70-
Fetch the model's registered ``SearchIndex`` in a standarized way.
70+
Fetch the model's registered ``SearchIndex`` in a standardized way.
7171
"""
7272
try:
7373
using_backends = connection_router.for_write(**{'models': [model_class]})
@@ -117,7 +117,7 @@ def run(self, action, identifier, **kwargs):
117117
raise ValueError("Couldn't load object '%s'" % identifier)
118118

119119
# Call the appropriate handler of the current index and
120-
# handle exception if neccessary
120+
# handle exception if necessary
121121
try:
122122
current_index.update_object(instance, using=using)
123123
except Exception as exc:

celery_haystack/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_update_task(task_path=None):
2828

2929
def enqueue_task(action, instance, **kwargs):
3030
"""
31-
Common utility for enqueing a task for the given action and
31+
Common utility for enqueuing a task for the given action and
3232
model instance.
3333
"""
3434
identifier = get_identifier(instance)
@@ -39,7 +39,9 @@ def enqueue_task(action, instance, **kwargs):
3939
options['countdown'] = settings.CELERY_HAYSTACK_COUNTDOWN
4040

4141
task = get_update_task()
42-
task_func = lambda: task.apply_async((action, identifier), kwargs, **options)
42+
task_func = lambda: task.apply_async( # noqa: E731
43+
(action, identifier), kwargs, **options
44+
)
4345

4446
if hasattr(transaction, 'on_commit'):
4547
# Django 1.9 on_commit hook

docs/changelog.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ v0.9 (2015-06-13)
1313
* Added ``CELERY_HAYSTACK_COUNTDOWN`` setting to define when to start the
1414
indexing task after initially creating it.
1515

16-
* Stop returning after after enqueing in the Haystack router to support
17-
multple routers.
16+
* Stop returning after enqueuing in the Haystack router to support
17+
multiple routers.
1818

1919
* Optionally support using django-transaction-hooks for improved transaction
2020
handling.
@@ -26,7 +26,7 @@ v0.9 (2015-06-13)
2626
v0.8 (2014-07-31)
2727
-----------------
2828

29-
* Fix bug when using multiple Haystack indizes
29+
* Fix bug when using multiple Haystack indices
3030

3131
* Fixed merge bug where primary key of object was cast to int
3232

@@ -44,7 +44,7 @@ v0.7.2 (2013-03-23)
4444
v0.7.1 (2013-03-09)
4545
-------------------
4646

47-
* Fixed an installation issues with d2to1.
47+
* Fixed installation issues with d2to1.
4848

4949
v0.7 (2013-03-09)
5050
-----------------
@@ -118,7 +118,7 @@ v0.4 (2011-09-17)
118118
Please rebuild your Haystack indexes using the ``rebuild_index``
119119
management command.
120120

121-
* Addded initial Sphinx documentation: http://celery-haystack.rtfd.org
121+
* Added initial Sphinx documentation: http://celery-haystack.rtfd.org
122122

123123
* Revamped the tets to test the search results, not only queuing.
124124

@@ -132,7 +132,7 @@ v0.3 (2011-08-22)
132132

133133
* Moved configuration defaults handling to django-appconf_.
134134

135-
* Fixed issue that occured when retrying a task.
135+
* Fixed issue that occurred when retrying a task.
136136

137137
.. _django-appconf: http://pypi.python.org/pypi/django-appconf
138138

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14-
import sys, os
14+
# import os
15+
# import sys
1516

1617
# If extensions (or modules to document with autodoc) are in another directory,
1718
# add these directories to sys.path here. If the directory is relative to the

0 commit comments

Comments
 (0)