Skip to content

Commit

Permalink
Bump ruff from 0.0.289 to 0.1.13 (#5)
Browse files Browse the repository at this point in the history
* Bump ruff from 0.0.289 to 0.1.13

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.0.289 to 0.1.13.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@v0.0.289...v0.1.13)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Refactor codebase according to PEP 8 and other style guidelines

The submitted changes updated various areas of the codebase to conform to style recommendations such as PEP 8. Changes include converting single quotes to double quotes for string literals, refactoring multi-line code statements, and renaming variable identifiers for clarity. Additionally, configuration options in `pyproject.toml` and error handling approaches have been altered for better efficiency and readability.

* Update lint command in CI workflow

The lint command in the Github continuous integration workflow has been updated to apply automatic fixes and preview changes. It also includes an unsafe mode to apply more extensive changes that may not preserve the exact original semantics.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: meanmail <[email protected]>
  • Loading branch information
dependabot[bot] and meanmail authored Jan 15, 2024
1 parent 6cadfaa commit 7f80cb6
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: poetry install --only main,dev --no-interaction --no-ansi --no-cache

- name: Lint
run: poetry run ruff .
run: poetry run ruff --unsafe-fixes --preview --fix .

type_checking:
name: Static type checking
Expand Down
53 changes: 26 additions & 27 deletions poetry.lock

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

111 changes: 58 additions & 53 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ voluptuous = "^0.14.1"
[tool.poetry.group.dev.dependencies]
black = "^23.3.0"
mypy = "^1.4.1"
ruff = "^0.0.289"
ruff = "^0.1.13"
types-pytz = ">=2023.3.0.0"

[build-system]
Expand All @@ -28,70 +28,83 @@ build-backend = "poetry.core.masonry.api"

[tool.ruff]
select = [
"A",
"ANN",
"B",
"BLE",
"C4",
"C90",
"COM",
"D",
"DJ",
"DTZ",
"E",
"ERA",
"EXE",
"F",
"G",
"I",
"ICN",
"INP",
"INT",
"ISC",
"N",
"NPY",
"PD",
"PGH",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"Q",
"RET",
"RSE",
"RUF",
"S",
"SIM",
"SLF",
"T10",
"T20",
"TCH",
"TID",
"TRY",
"UP",
"W",
"YTT",
"ALL",
]
ignore = [
"A001",
"A003",
"ANN001",
"ANN002",
"ANN003",
"ANN101",
"ANN102",
"ANN201",
"ANN202",
"ANN204",
"ANN206",
"ANN401",
"ARG001",
"ARG002",
"B023",
"BLE001",
"COM812",
"CPY001",
"D100",
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D107",
"D205",
"DTZ001",
"DTZ004",
"DTZ006",
"DTZ012",
"E203",
"E741",
"EXE002",
"F403",
"FBT001",
"FBT002",
"FBT003",
"FIX002",
"INP001",
"ISC001",
"N802",
"N806",
"N818",
"PIE804",
"PLC1901",
"PLR2004",
"PLR6301",
"PLW0603",
"PLW2901",
"PT011",
"PT012",
"PTH100",
"PTH102",
"PTH110",
"PTH111",
"PTH112",
"PTH118",
"PTH120",
"PTH123",
"RUF012",
"S101",
"S105",
"S110",
"S311",
"S602",
"S603",
"S607",
"SIM108",
"SLF001",
"TD002",
"TD003",
"TRY003",
"TRY301",
]

# Exclude a variety of commonly ignored directories.
Expand Down Expand Up @@ -126,9 +139,6 @@ max-complexity = 14
[tool.ruff.pydocstyle]
convention = "google"

[tool.ruff.flake8-quotes]
inline-quotes = "single"

[tool.ruff.pep8-naming]
classmethod-decorators = [
"classmethod",
Expand All @@ -148,11 +158,6 @@ known-third-party = ["elasticsearch"]
order-by-type = false
required-imports = ["from __future__ import annotations"]

[tool.black]
line-length = 100
target-version = ['py311']
skip-string-normalization = true

[tool.mypy]
python_version = "3.11"
check_untyped_defs = true
Expand Down
10 changes: 5 additions & 5 deletions stepic_plugins/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
)

__all__ = [
'PluginError',
'FormatError',
'QuizSetUpError',
'UnknownPluginError',
'PluginTimeoutError',
"PluginError",
"FormatError",
"QuizSetUpError",
"UnknownPluginError",
"PluginTimeoutError",
]
4 changes: 2 additions & 2 deletions stepik_plugins_client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def __init__(
message = truncate_data(message, max_length=USER_OUTPUT_MAX_LENGTH)
params = truncate_data(params, max_length=USER_OUTPUT_MAX_LENGTH)
super().__init__(message, code, params)
self.message = message or ''
self.code = code or ''
self.message = message or ""
self.code = code or ""
self.params = params or {}


Expand Down
34 changes: 18 additions & 16 deletions stepik_plugins_client/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@


class WrappedEndpointMetaclass(type):
def __new__( # noqa: PYI034
def __new__(
cls, name: str, bases: tuple[type, ...], dct: dict[str, Any]
) -> WrappedEndpointMetaclass:
"""Create API class."""
instance = super().__new__(cls, name, bases, dct)
for name in dir(instance):
method = getattr(instance, name)
if not name.startswith('_') and callable(method):
setattr(instance, name, cls.method_wrapper(method))
for _name in dir(instance):
method = getattr(instance, _name)
if not _name.startswith("_") and callable(method):
setattr(instance, _name, cls.method_wrapper(method))
return instance

@staticmethod
Expand All @@ -40,10 +40,11 @@ def wrapper(self: Any, *args, **kwargs) -> Any:
try:
return method(self, *args, **kwargs)
except MessagingTimeout as exception:
raise PluginTimeoutError(
'A timeout occurred while calling Problem API. '
'It looks like calculations take a long time.'
) from exception
msg = (
"A timeout occurred while calling Problem API. "
"It looks like calculations take a long time."
)
raise PluginTimeoutError(msg) from exception

return wrapper

Expand All @@ -58,26 +59,27 @@ class ReportedUtilsAPI(rpcapi.UtilsAPI, metaclass=WrappedEndpointMetaclass):

@overload
def _get_rpcapi_client(
name: Literal['quiz'], transport_url: str, topic: str | None = None, timeout: int = 5 * 60
name: Literal["quiz"], transport_url: str, topic: str | None = None, timeout: int = 5 * 60
) -> ReportedQuizAPI:
...


@overload
def _get_rpcapi_client(
name: Literal['utils'], transport_url: str, topic: str | None = None, timeout: int = 5 * 60
name: Literal["utils"], transport_url: str, topic: str | None = None, timeout: int = 5 * 60
) -> ReportedUtilsAPI:
...


def _get_rpcapi_client(name, transport_url, topic=None, timeout=5 * 60):
api_class_map = {
'quiz': ReportedQuizAPI,
'utils': ReportedUtilsAPI,
"quiz": ReportedQuizAPI,
"utils": ReportedUtilsAPI,
}
rpc_api_class = api_class_map.get(name)
if not rpc_api_class:
raise ValueError('Incorrect RPC API client name')
msg = "Incorrect RPC API client name"
raise ValueError(msg)
key = (name, transport_url, topic)
if name not in _RPC_API_CLIENTS:
rpcapi.set_default_response_timeout(timeout)
Expand All @@ -89,11 +91,11 @@ def quiz_rpcapi(
transport_url: str, topic: str | None = None, timeout: int = 5 * 60 * SECOND
) -> ReportedQuizAPI:
"""Get client for the quizzes RPC API."""
return _get_rpcapi_client('quiz', transport_url, topic, timeout)
return _get_rpcapi_client("quiz", transport_url, topic, timeout)


def utils_rpcapi(
transport_url: str, topic: str | None = None, timeout: int = 5 * 60 * SECOND
) -> ReportedUtilsAPI:
"""Get client for the utils RPC API."""
return _get_rpcapi_client('utils', transport_url, topic, timeout)
return _get_rpcapi_client("utils", transport_url, topic, timeout)
Loading

0 comments on commit 7f80cb6

Please sign in to comment.