Skip to content

Commit

Permalink
switch from black/flake8 to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcarneiro committed Mar 23, 2024
1 parent e9e3a9f commit c656fa6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: tox
on: [push, pull_request]
jobs:
tox-flake8:
tox-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- run: pip install --upgrade pip
- run: pip install tox
- run: tox -e flake8
- run: tox -e lint

tox-mypy:
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[tool.black]
line-length = 79
target_version = ['py37']
target_version = ['py310']

[tool.ruff]
target-version = "py310"
line-length = 79

[tool.pytest.ini_options]
asyncio_mode = "auto"
15 changes: 10 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
[tox]
envlist = py310, py311, py312, flake8, mypy
envlist = py310, py311, py312, lint, mypy

[travis]
python =
3.10: py310
3.11: py311
3.12: py312

[testenv:flake8]
basepython=python3
deps=flake8
commands=flake8 --max-line-length=88 yacron tests

[testenv:lint]
description = lint source code
deps =
ruff
commands =
ruff check yacron
ruff format --check yacron


[testenv:mypy]
basepython=python3
Expand Down
4 changes: 1 addition & 3 deletions yacron/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,7 @@ def __init__(self, config: dict) -> None:
self.schedule_unparsed = config.pop("schedule")
if isinstance(self.schedule_unparsed, str):
if self.schedule_unparsed in {"@reboot"}:
self.schedule = (
self.schedule_unparsed
) # type: Union[CronTab, str]
self.schedule = self.schedule_unparsed # type: Union[CronTab, str]
else:
self.schedule = CronTab(self.schedule_unparsed)
elif isinstance(self.schedule_unparsed, dict):
Expand Down
22 changes: 11 additions & 11 deletions yacron/cron.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import logging.config
import asyncio
import asyncio.subprocess
import datetime
import logging
import logging.config
from collections import OrderedDict, defaultdict
from typing import Any, Awaitable, Dict, List, Optional, Union # noqa
from urllib.parse import urlparse

from aiohttp import web
from crontab import CronTab # noqa

import yacron.version
from yacron.config import (
JobConfig,
parse_config,
ConfigError,
parse_config_string,
JobConfig,
JobDefaults,
WebConfig,
YacronConfig,
JobDefaults,
parse_config,
parse_config_string,
)
from yacron.job import RunningJob, JobRetryState
from crontab import CronTab # noqa
from yacron.job import JobRetryState, RunningJob

logger = logging.getLogger("yacron")
WAKEUP_INTERVAL = datetime.timedelta(minutes=1)
Expand Down Expand Up @@ -77,9 +79,7 @@ def __init__(
self.cron_jobs = OrderedDict() # type: Dict[str, JobConfig]
# list of cron jobs already running
# name -> list of RunningJob
self.running_jobs = defaultdict(
list
) # type: Dict[str, List[RunningJob]]
self.running_jobs = defaultdict(list) # type: Dict[str, List[RunningJob]]
self.config_arg = config_arg
if config_arg is not None:
self.update_config()
Expand Down Expand Up @@ -212,7 +212,7 @@ async def _web_get_status(self, request: web.Request) -> web.Response:
status = "scheduled ({})".format(
(
jobstat["scheduled_in"]
if type(jobstat["scheduled_in"]) is str
if isinstance(jobstat["scheduled_in"], str)
else naturaltime(
jobstat["scheduled_in"], future=True
)
Expand Down
7 changes: 3 additions & 4 deletions yacron/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
import asyncio.subprocess
import logging
import os
import subprocess
import sys
import time
from datetime import datetime, timezone
from email.message import EmailMessage
from socket import gethostname
from typing import Any, Dict, List, Optional, Tuple
import subprocess

import sentry_sdk
import sentry_sdk.utils

import aiosmtplib
import jinja2
import sentry_sdk
import sentry_sdk.utils

from yacron.config import JobConfig
from yacron.statsd import StatsdJobMetricWriter
Expand Down

0 comments on commit c656fa6

Please sign in to comment.