Skip to content

Commit 5bd7d6e

Browse files
chore: introduce ruff to replace flake8 (#53)
Flake8 was recently removed, this MR introduces ruff to perform the same checks.
1 parent 807e212 commit 5bd7d6e

15 files changed

Lines changed: 650 additions & 535 deletions

File tree

.github/workflows/checks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ jobs:
5858
- name: Run pylint
5959
run: poetry run task pylint
6060

61+
- name: Run ruff
62+
run: poetry run task ruff
63+
6164
- name: Run pytest
6265
run: poetry run task test
6366
env:

lib/binarylane/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" Contains some shared types for properties """
2+
23
from __future__ import annotations
34

45
from http import HTTPStatus

poetry.lock

Lines changed: 609 additions & 512 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ types-python-dateutil = "^2.8.19"
2525
pytest = "^7.2.0"
2626
absolufy-imports = "^0.3.1"
2727
binarylane-python-client = "^0.13.2a0"
28-
safety = "*"
28+
safety = "<3.0.0"
29+
ruff = "^0.9.6"
2930

3031
[tool.poetry.group.pylint.dependencies]
3132
pylint = { version = "^3.3.4", python = ">=3.9" }
@@ -38,10 +39,11 @@ generate = "python scripts/generate.py"
3839
black = "black ."
3940
isort = "isort ."
4041
mypy = "mypy ."
42+
ruff = "ruff check src"
4143
pylint = "pylint src"
4244
safety = "poetry export -f requirements.txt | safety check --bare --stdin"
4345
test = "pytest tests"
44-
check = "task isort && task black && task mypy && task pylint && task test && task safety"
46+
check = "task isort && task black && task mypy && task ruff && task pylint && task test && task safety"
4547

4648
[tool.isort]
4749
py_version = 37
@@ -58,6 +60,17 @@ add_imports=["from __future__ import annotations"]
5860
line-length = 120
5961
target_version = ["py37"]
6062

63+
[tool.ruff]
64+
# Always generate Python 3.8-compatible code.
65+
target-version = "py38"
66+
line-length = 120
67+
exclude = [
68+
"api", # generated command classes
69+
]
70+
71+
[tool.ruff.lint]
72+
select = ["E4", "E7", "E9", "F", "TC"]
73+
6174
[tool.pylint.format]
6275
max-line-length = 120
6376
ignore-paths = ['src/binarylane/console/commands/*/']

scripts/generate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Generate updated API bindings and CLI commands from OpenAPI specification document"""
2+
23
from __future__ import annotations
34

45
import re

src/binarylane/config/options.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ class OptionAttributes(ABC):
2222
UNCONFIGURED_TOKEN: ClassVar[str] = "unconfigured"
2323

2424
@abstractmethod
25-
def get_option(self, name: OptionName) -> Optional[str]:
26-
...
25+
def get_option(self, name: OptionName) -> Optional[str]: ...
2726

2827
@abstractmethod
29-
def required_option(self, name: OptionName) -> str:
30-
...
28+
def required_option(self, name: OptionName) -> str: ...
3129

3230
@abstractmethod
33-
def add_option(self, name: OptionName, value: str) -> None:
34-
...
31+
def add_option(self, name: OptionName, value: str) -> None: ...
3532

3633
@staticmethod
3734
def to_bool(name: str) -> bool:

src/binarylane/config/repository.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111

1212
class Source(Protocol):
13-
def get(self, name: str) -> Optional[str]:
14-
...
13+
def get(self, name: str) -> Optional[str]: ...
1514

1615

1716
T = TypeVar("T", bound=Source)

src/binarylane/config/sources.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from __future__ import annotations
22

3-
import argparse
43
import configparser
54
import os
65
import sys
76
from abc import ABC
87
from pathlib import Path
9-
from typing import ClassVar, Dict, Optional
8+
from typing import TYPE_CHECKING, ClassVar, Dict, Optional
9+
10+
if TYPE_CHECKING:
11+
import argparse
1012

1113

1214
class _SourceBase(ABC):

src/binarylane/console/commands/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" Contains methods for accessing the API """
2+
23
from __future__ import annotations
34

45
import re

src/binarylane/console/parser/attribute.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from __future__ import annotations
22

3-
import argparse
43
import logging
54
from abc import ABC, abstractmethod
65
from typing import TYPE_CHECKING, ClassVar, List, Optional
76

87
logger = logging.getLogger(__name__)
98

109
if TYPE_CHECKING:
10+
import argparse
11+
1112
from binarylane.console.parser.object_attribute import ObjectAttribute
1213
from binarylane.console.parser.parser import Parser
1314

@@ -62,12 +63,10 @@ def group_name(self) -> Optional[str]:
6263
return self.parent.group_name if self.parent else None
6364

6465
@abstractmethod
65-
def configure(self, parser: Parser) -> None:
66-
...
66+
def configure(self, parser: Parser) -> None: ...
6767

6868
@abstractmethod
69-
def construct(self, parser: Parser, parsed: argparse.Namespace) -> object:
70-
...
69+
def construct(self, parser: Parser, parsed: argparse.Namespace) -> object: ...
7170

7271
def _unsupported(self, message: str, error: bool = True) -> None:
7372
"""Report that command parsing is not likely to work correctly"""

0 commit comments

Comments
 (0)