Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GitHub Action to run codespell and ruff #82

Merged
merged 11 commits into from
Jul 23, 2023
19 changes: 19 additions & 0 deletions .github/workflows/codespell_and_ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This Action uses minimal steps to run in ~5 seconds to rapidly:
# find typos in the codebase using codespell, and
# lint Python code using ruff and provide intuitive GitHub Annotations to contributors.
# https://github.com/codespell-project/codespell#readme
# https://beta.ruff.rs
name: codespell_and_ruff
on:
push:
branches: [develop]
pull_request:
branches: [develop]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pip install --user codespell[toml] ruff
- run: codespell # --ignore-words-list="" --skip="*.css,*.js,*.lock,*.po"
- run: ruff --format=github --target-version=py38 .
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# To enable this pre-commit hook run:
# `pip install pre-commit` or `brew install pre-commit`
# Then run `pre-commit install`

# Learn more about this config here: https://pre-commit.com/
default_language_version:
python: python3.11

ci:
submodules: true

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.278
hooks:
- id: ruff # See pyproject.toml for args

- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell # See pyproject.toml for args
additional_dependencies:
- tomli
10 changes: 5 additions & 5 deletions celery_haystack/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def split_identifier(self, identifier, **kwargs):

if len(bits) < 2:
logger.error("Unable to parse object "
"identifer '%s'. Moving on..." % identifier)
"identifier '%s'. Moving on..." % identifier)
return (None, None)

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

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

def get_instance(self, model_class, pk, **kwargs):
"""
Fetch the instance in a standarized way.
Fetch the instance in a standardized way.
"""
instance = None
try:
Expand All @@ -67,7 +67,7 @@ def get_instance(self, model_class, pk, **kwargs):

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

# Call the appropriate handler of the current index and
# handle exception if neccessary
# handle exception if necessary
try:
current_index.update_object(instance, using=using)
except Exception as exc:
Expand Down
6 changes: 4 additions & 2 deletions celery_haystack/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_update_task(task_path=None):

def enqueue_task(action, instance, **kwargs):
"""
Common utility for enqueing a task for the given action and
Common utility for enqueuing a task for the given action and
model instance.
"""
identifier = get_identifier(instance)
Expand All @@ -39,7 +39,9 @@ def enqueue_task(action, instance, **kwargs):
options['countdown'] = settings.CELERY_HAYSTACK_COUNTDOWN

task = get_update_task()
task_func = lambda: task.apply_async((action, identifier), kwargs, **options)
task_func = lambda: task.apply_async( # noqa: E731
(action, identifier), kwargs, **options
)

if hasattr(transaction, 'on_commit'):
# Django 1.9 on_commit hook
Expand Down
12 changes: 6 additions & 6 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ v0.9 (2015-06-13)
* Added ``CELERY_HAYSTACK_COUNTDOWN`` setting to define when to start the
indexing task after initially creating it.

* Stop returning after after enqueing in the Haystack router to support
multple routers.
* Stop returning after enqueuing in the Haystack router to support
multiple routers.

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

* Fix bug when using multiple Haystack indizes
* Fix bug when using multiple Haystack indices

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

Expand All @@ -44,7 +44,7 @@ v0.7.2 (2013-03-23)
v0.7.1 (2013-03-09)
-------------------

* Fixed an installation issues with d2to1.
* Fixed installation issues with d2to1.

v0.7 (2013-03-09)
-----------------
Expand Down Expand Up @@ -118,7 +118,7 @@ v0.4 (2011-09-17)
Please rebuild your Haystack indexes using the ``rebuild_index``
management command.

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

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

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

* Moved configuration defaults handling to django-appconf_.

* Fixed issue that occured when retrying a task.
* Fixed issue that occurred when retrying a task.

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

Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
# import os
# import sys

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