diff options
author | Rob Hudson <robhudson@mozilla.com> | 2023-05-17 09:19:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 23:19:14 +0700 |
commit | ea063edf0a790630d0800808fe6236b3e9ddcf22 (patch) | |
tree | ead2cb88df0fd1a7b4d03f578d9aa9692381e566 /rq/job.py | |
parent | bbfeb8c8ed2913e980412ee7606c171fdf37e713 (diff) | |
download | rq-ea063edf0a790630d0800808fe6236b3e9ddcf22.tar.gz |
Update linting configuration (#1915)
* Update linting configuration
This removes flake8 in favor of ruff, which also provides isort support, and
updates all files to be black, isort, and ruff compliant. This also adds black
and ruff checks to the tox and Github linting workflow.
* Tweak the code coverage config and calls
Diffstat (limited to 'rq/job.py')
-rw-r--r-- | rq/job.py | 34 |
1 files changed, 19 insertions, 15 deletions
@@ -1,25 +1,26 @@ +import asyncio import inspect import json import logging import warnings import zlib -import asyncio - from datetime import datetime, timedelta, timezone from enum import Enum -from redis import WatchError -from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Union, Type +from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union from uuid import uuid4 +from redis import WatchError + from .defaults import CALLBACK_TIMEOUT, UNSERIALIZABLE_RETURN_VALUE_PAYLOAD -from .timeouts import JobTimeoutException, BaseDeathPenalty +from .timeouts import BaseDeathPenalty, JobTimeoutException if TYPE_CHECKING: - from .results import Result - from .queue import Queue from redis import Redis from redis.client import Pipeline + from .queue import Queue + from .results import Result + from .connections import resolve_connection from .exceptions import DeserializationError, InvalidJobOperation, NoSuchJobError from .local import LocalStack @@ -167,8 +168,8 @@ class Job: func (FunctionReference): The function/method/callable for the Job. This can be a reference to a concrete callable or a string representing the path of function/method to be imported. Effectively this is the only required attribute when creating a new Job. - args (Union[List[Any], Optional[Tuple]], optional): A Tuple / List of positional arguments to pass the callable. - Defaults to None, meaning no args being passed. + args (Union[List[Any], Optional[Tuple]], optional): A Tuple / List of positional arguments to pass the + callable. Defaults to None, meaning no args being passed. kwargs (Optional[Dict], optional): A Dictionary of keyword arguments to pass the callable. Defaults to None, meaning no kwargs being passed. connection (Optional[Redis], optional): The Redis connection to use. Defaults to None. @@ -179,13 +180,16 @@ class Job: status (JobStatus, optional): The Job Status. Defaults to None. description (Optional[str], optional): The Job Description. Defaults to None. depends_on (Union['Dependency', List[Union['Dependency', 'Job']]], optional): What the jobs depends on. - This accepts a variaty of different arguments including a `Dependency`, a list of `Dependency` or a `Job` - list of `Job`. Defaults to None. - timeout (Optional[int], optional): The amount of time in seconds that should be a hardlimit for a job execution. Defaults to None. + This accepts a variaty of different arguments including a `Dependency`, a list of `Dependency` or a + `Job` list of `Job`. Defaults to None. + timeout (Optional[int], optional): The amount of time in seconds that should be a hardlimit for a job + execution. Defaults to None. id (Optional[str], optional): An Optional ID (str) for the Job. Defaults to None. origin (Optional[str], optional): The queue of origin. Defaults to None. - meta (Optional[Dict[str, Any]], optional): Custom metadata about the job, takes a dictioanry. Defaults to None. - failure_ttl (Optional[int], optional): THe time to live in seconds for failed-jobs information. Defaults to None. + meta (Optional[Dict[str, Any]], optional): Custom metadata about the job, takes a dictioanry. + Defaults to None. + failure_ttl (Optional[int], optional): THe time to live in seconds for failed-jobs information. + Defaults to None. serializer (Optional[str], optional): The serializer class path to use. Should be a string with the import path for the serializer to use. eg. `mymodule.myfile.MySerializer` Defaults to None. on_success (Optional[Callable[..., Any]], optional): A callback function, should be a callable to run @@ -1081,8 +1085,8 @@ class Job: """ if self.is_canceled: raise InvalidJobOperation("Cannot cancel already canceled job: {}".format(self.get_id())) - from .registry import CanceledJobRegistry from .queue import Queue + from .registry import CanceledJobRegistry pipe = pipeline or self.connection.pipeline() |