Skip to content

Commit

Permalink
Merge pull request #339 from ClearcodeHQ/ruff
Browse files Browse the repository at this point in the history
Replace pydocstyle and pycodestyle with ruff - closes #285
  • Loading branch information
fizyk authored Oct 16, 2023
2 parents 7f6d8af + 3f67640 commit b9ef320
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 57 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ jobs:
pipenv-install-options: "--skip-lock"
mypy: true
black: true
pycodestyle: true
pydocstyle: true
ruff: true
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ types-requests = "==2.31.0.9"

[dev-packages]
towncrier = "==23.6.0"
pydocstyle = {version = "==6.3.0", extras = ["toml"]}
pycodestyle = "==2.11.1"
mypy = "==1.6.0"
black = "==23.9.1"
pytest = "==7.4.2"
pytest-cov = "==4.1.0"
tbump = "==6.11.0"
sphinx = "==7.2.6"
sphinx-jsonschema = "==1.19.1"
ruff = "==0.0.292"
46 changes: 25 additions & 21 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.

from pathlib import Path
from typing import List, Dict

from typing import Dict, List

p = Path(os.getcwd())
sys.path.append(str(p.parent.parent))
Expand Down
38 changes: 15 additions & 23 deletions jira_timemachine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

"""Module for synchronization of Jira worklogs between different instances."""

import re
import itertools
from datetime import date, timedelta
import re
from dataclasses import dataclass
from typing import Iterator, Dict, IO, Optional, Tuple, Union
from datetime import date, timedelta
from typing import IO, Dict, Iterator, Optional, Tuple, Union

import click
import arrow
from jira import JIRA
import click
import jira
from jira.client import ResultList
from pydantic import BaseModel, HttpUrl, Field, ValidationError
import requests
from jira import JIRA
from jira.client import ResultList
from pydantic import BaseModel, Field, HttpUrl, ValidationError
from requests import HTTPError

__version__ = "1.0.1"
Expand Down Expand Up @@ -98,8 +98,7 @@ def to_tempo(self) -> dict:


class TempoClient:
"""
A client for Tempo Cloud APIs.
"""A client for Tempo Cloud APIs.
See <https://tempo-io.github.io/tempo-api-docs/> for the API documentation.
"""
Expand All @@ -111,8 +110,7 @@ def __init__(self, tempo_token: str, account_id: str) -> None:
self.session.headers.update({"Authorization": "Bearer %s" % tempo_token})

def get_worklogs(self, from_date: date, single_user: bool = True) -> Iterator[Worklog]:
"""
Return all recent worklogs for the specified user.
"""Return all recent worklogs for the specified user.
:returns: yields Worklog instances
"""
Expand Down Expand Up @@ -156,8 +154,7 @@ def get_worklogs(self, from_date: date, single_user: bool = True) -> Iterator[Wo
url = response_data["metadata"].get("next")

def update_worklog(self, worklog: Worklog) -> None:
"""
Update the specified worklog.
"""Update the specified worklog.
:param worklog: updated worklog data
"""
Expand All @@ -171,8 +168,7 @@ def update_worklog(self, worklog: Worklog) -> None:
raise

def post_worklog(self, worklog: Worklog) -> None:
"""
Upload a new worklog.
"""Upload a new worklog.
:param worklog: new worklog data
"""
Expand Down Expand Up @@ -223,8 +219,7 @@ def _issues(self, query: str) -> Iterator[jira.Issue]:
return

def get_worklogs(self, from_date: date, single_user: bool = True) -> Iterator[Worklog]:
"""
Return all recent worklogs for the specified user.
"""Return all recent worklogs for the specified user.
:returns: yields Worklog instances
"""
Expand Down Expand Up @@ -258,8 +253,7 @@ def get_client(config: SourceJiraConfig) -> Union[TempoClient, JIRAClient]:


def get_worklogs(config: SourceJiraConfig, since: arrow.Arrow, all_users: bool = False) -> Iterator[Worklog]:
"""
Yield user's recent worklogs.
"""Yield user's recent worklogs.
:param config: JIRA configuration
:param since: earliest start time of yielded worklogs
Expand All @@ -276,8 +270,7 @@ def get_worklogs(config: SourceJiraConfig, since: arrow.Arrow, all_users: bool =


def format_time(seconds: int) -> str:
"""
Return *seconds* in a human-readable format (e.g. 25h 15m 45s).
"""Return *seconds* in a human-readable format (e.g. 25h 15m 45s).
Unlike `timedelta`, we don't aggregate it into days: it's not useful when reporting logged work hours.
"""
Expand All @@ -298,8 +291,7 @@ def format_time(seconds: int) -> str:


def match_worklog(source_worklogs: Dict[int, Worklog], worklog: Worklog) -> Optional[Worklog]:
"""
Return a matching source worklog for the given destination worklog.
"""Return a matching source worklog for the given destination worklog.
:param source_worklogs: a mapping from source JIRA worklog ID to `Worklog` instance
:param worklog: destination JIRA worklog
Expand Down
1 change: 1 addition & 0 deletions newsfragments/285.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace pydocstyle and pycodestyle with ruff
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ line-length = 120
target-version = ['py310']
include = '.*\.pyi?$'

[tool.ruff]
# Decrease the maximum line length to 79 characters.
line-length = 120
select = [
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"D", # pydocstyle
]


[tool.mypy]
check_untyped_defs = true
mypy_path = "src"
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg

This file was deleted.

6 changes: 3 additions & 3 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

from datetime import date
from io import StringIO
from unittest.mock import patch, call, Mock
from unittest.mock import Mock, call, patch

import arrow
import click
import pytest
from pydantic import HttpUrl, parse_obj_as, TypeAdapter
from pydantic import HttpUrl, TypeAdapter
from pydantic_core import Url

from jira_timemachine import Worklog, get_worklogs, format_time, match_worklog, SourceJiraConfig, get_config
from jira_timemachine import SourceJiraConfig, Worklog, format_time, get_config, get_worklogs, match_worklog


def test_worklog_to_tempo():
Expand Down

0 comments on commit b9ef320

Please sign in to comment.