Skip to content

Commit b7460d1

Browse files
refactor(format): replace Black with Ruff formatter
1 parent bc75ba4 commit b7460d1

File tree

25 files changed

+80
-119
lines changed

25 files changed

+80
-119
lines changed

.cursor/rules/checks.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ alwaysApply: true
2020

2121
**Avoid Over-Engineering**: Do not add speculative generality or unnecessary abstractions unless required.
2222

23-
**Consistent Formatting**: Follow PEP 8, Black (line length 120 characters), and project-specific style (e.g., Pydantic Field descriptions). Use double quotes for strings.
23+
**Consistent Formatting**: Follow PEP 8, Ruff formatter (line length 120 characters), and project-specific style (e.g., Pydantic Field descriptions). Use double quotes for strings.
2424

2525
**Modular Design**: Organize code into modules (e.g., archipy.configs, archipy.helpers.utils) to minimize coupling and avoid divergent changes.
2626

@@ -214,7 +214,7 @@ class ElasticsearchConfig(BaseModel):
214214
**Package Management**: `uv sync --all-extras --all-groups` or `make install-dev`
215215

216216
**Workflow**:
217-
- Format: `make format` (Black, 120 chars)
217+
- Format: `make format` (Ruff formatter, 120 chars)
218218
- Lint: `make lint` (Ruff + Ty)
219219
- Test: `make behave`
220220
- Security: `make security` (Bandit)

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ repos:
5858
entry: uv run codespell --toml pyproject.toml
5959
files: \.(py|pyi)$
6060
language: system
61-
- id: black
62-
name: black
63-
entry: uv run black --config pyproject.toml
61+
- id: ruff-format
62+
name: ruff-format
63+
entry: uv run ruff format --config pyproject.toml
6464
files: \.(py|pyi)$
6565
language: system
6666
exclude: ^(features|scripts)/

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
55
## Commands
66

77
- **Setup**: `uv sync --all-extras --all-groups` or `make install-dev`
8-
- **Format**: `make format` (Black, 120 char line length)
8+
- **Format**: `make format` (Ruff formatter, 120 char line length)
99
- **Lint**: `make lint` (Ruff + Ty)
1010
- **Test**: `make behave` (all tests with Behave BDD framework)
1111
- **Single test**: `uv run --extra behave behave features/file_name.feature`

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ make update
121121
#### Code Quality
122122

123123
```bash
124-
# Format code with black
124+
# Format code with Ruff formatter
125125
make format
126126

127127
# Run all linters (ruff, ty)

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ clean: ## Remove build artifacts and cache directories
6969
find . -type f -name "*.pyc" -delete
7070

7171
.PHONY: format
72-
format: ## Format code using black
72+
format: ## Format code using ruff
7373
@echo "${BLUE}Formatting code...${NC}"
74-
$(PYTHON) black --config pyproject.toml $(PYTHON_FILES)
74+
$(PYTHON) ruff format --config pyproject.toml $(PYTHON_FILES)
7575

7676
.PHONY: lint
7777
lint: ## Run all linters
@@ -147,7 +147,7 @@ pre-commit: ## Run pre-commit hooks
147147
$(PRE_COMMIT) run --all-files
148148

149149
.PHONY: check
150-
check: lint security behave ## Run all checks (linting, security, and tests)
150+
check: format lint security behave ## Run all checks (format, linting, security, and tests)
151151

152152
.PHONY: ci
153153
ci: ## Run CI pipeline locally

archipy/adapters/email/ports.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class EmailPort:
2121
email service, managing connections, and ensuring reliable delivery.
2222
2323
Examples:
24-
>>> from archipy.adapters.email.email_port import EmailPort
24+
>>> from archipy.adapters.email.ports import EmailPort
2525
>>>
2626
>>> class CustomEmailAdapter(EmailPort):
2727
... def __init__(self, config):
@@ -37,7 +37,7 @@ class EmailPort:
3737
... attachments=None,
3838
... html=False,
3939
... template=None,
40-
... template_vars=None
40+
... template_vars=None,
4141
... ):
4242
... # Implementation details...
4343
... pass
@@ -77,19 +77,15 @@ def send_email(
7777
7878
Examples:
7979
>>> # Simple text email
80-
>>> adapter.send_email(
81-
... to_email="[email protected]",
82-
... subject="Hello",
83-
... body="This is a test email"
84-
... )
80+
>>> adapter.send_email(to_email="[email protected]", subject="Hello", body="This is a test email")
8581
>>>
8682
>>> # HTML email with attachment
8783
>>> adapter.send_email(
8884
8985
... subject="Report",
9086
... body="<h1>Monthly Report</h1><p>Please see attached</p>",
9187
... html=True,
92-
... attachments=["path/to/report.pdf"]
88+
... attachments=["path/to/report.pdf"],
9389
... )
9490
>>>
9591
>>> # Template-based email
@@ -99,7 +95,7 @@ def send_email(
9995
... subject="Account Expiration",
10096
... body="", # Body will be rendered from template
10197
... template=template,
102-
... template_vars={"name": "John", "date": "2023-12-31"}
98+
... template_vars={"name": "John", "date": "2023-12-31"},
10399
... )
104100
"""
105101
raise NotImplementedError

archipy/adapters/minio/adapters.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,11 @@ def put_object(self, bucket_name: str, object_name: str, file_path: str) -> None
294294
argument_name=(
295295
"bucket_name, object_name or file_path"
296296
if not all([bucket_name, object_name, file_path])
297-
else "bucket_name" if not bucket_name else "object_name" if not object_name else "file_path"
297+
else "bucket_name"
298+
if not bucket_name
299+
else "object_name"
300+
if not object_name
301+
else "file_path"
298302
),
299303
)
300304
self._adapter.fput_object(bucket_name, object_name, file_path)
@@ -330,7 +334,11 @@ def get_object(self, bucket_name: str, object_name: str, file_path: str) -> None
330334
argument_name=(
331335
"bucket_name, object_name or file_path"
332336
if not all([bucket_name, object_name, file_path])
333-
else "bucket_name" if not bucket_name else "object_name" if not object_name else "file_path"
337+
else "bucket_name"
338+
if not bucket_name
339+
else "object_name"
340+
if not object_name
341+
else "file_path"
334342
),
335343
)
336344
self._adapter.fget_object(bucket_name, object_name, file_path)
@@ -363,7 +371,9 @@ def remove_object(self, bucket_name: str, object_name: str) -> None:
363371
argument_name=(
364372
"bucket_name or object_name"
365373
if not all([bucket_name, object_name])
366-
else "bucket_name" if not bucket_name else "object_name"
374+
else "bucket_name"
375+
if not bucket_name
376+
else "object_name"
367377
),
368378
)
369379
self._adapter.remove_object(bucket_name, object_name)
@@ -449,7 +459,9 @@ def stat_object(self, bucket_name: str, object_name: str) -> MinioObjectType:
449459
argument_name=(
450460
"bucket_name or object_name"
451461
if not all([bucket_name, object_name])
452-
else "bucket_name" if not bucket_name else "object_name"
462+
else "bucket_name"
463+
if not bucket_name
464+
else "object_name"
453465
),
454466
)
455467
obj = self._adapter.stat_object(bucket_name, object_name)
@@ -497,7 +509,9 @@ def presigned_get_object(self, bucket_name: str, object_name: str, expires: int
497509
argument_name=(
498510
"bucket_name or object_name"
499511
if not all([bucket_name, object_name])
500-
else "bucket_name" if not bucket_name else "object_name"
512+
else "bucket_name"
513+
if not bucket_name
514+
else "object_name"
501515
),
502516
)
503517
url = self._adapter.presigned_get_object(
@@ -544,7 +558,9 @@ def presigned_put_object(self, bucket_name: str, object_name: str, expires: int
544558
argument_name=(
545559
"bucket_name or object_name"
546560
if not all([bucket_name, object_name])
547-
else "bucket_name" if not bucket_name else "object_name"
561+
else "bucket_name"
562+
if not bucket_name
563+
else "object_name"
548564
),
549565
)
550566
url = self._adapter.presigned_put_object(
@@ -587,7 +603,9 @@ def set_bucket_policy(self, bucket_name: str, policy: str) -> None:
587603
argument_name=(
588604
"bucket_name or policy"
589605
if not all([bucket_name, policy])
590-
else "bucket_name" if not bucket_name else "policy"
606+
else "bucket_name"
607+
if not bucket_name
608+
else "policy"
591609
),
592610
)
593611
self._adapter.set_bucket_policy(bucket_name, policy)

archipy/adapters/temporal/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ async def custom_logic():
567567
# Custom database operations
568568
return await some_database_work()
569569
570+
570571
result = await self.execute_custom_atomic_operation(custom_logic)
571572
```
572573
"""

archipy/configs/base_config.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ class BaseConfig[R](BaseSettings):
9696
... DEBUG = True
9797
...
9898
... # Custom configuration
99-
... FEATURE_FLAGS = {
100-
... "new_ui": True,
101-
... "advanced_search": False
102-
... }
99+
... FEATURE_FLAGS = {"new_ui": True, "advanced_search": False}
103100
>>>
104101
>>> # Set as global configuration
105102
>>> config = MyAppConfig()

archipy/helpers/decorators/cache.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class CachedFunction[**P, R]:
1515
def expensive_function(x: int) -> int:
1616
return x * 2
1717
18+
1819
# First call executes the function
1920
result = expensive_function(5) # Returns 10
2021
@@ -135,6 +136,7 @@ def fetch_data(self, key: str) -> dict:
135136
# Expensive operation
136137
return {"data": key}
137138
139+
138140
service1 = DataService()
139141
service2 = DataService()
140142

0 commit comments

Comments
 (0)