Skip to content

Commit 3e4fd59

Browse files
committed
Remove stale pylint references and align CI with pre-commit
Remove all pylint inline comments left over after switching to ruff. Switch CI lint job from bare pip install ruff to pre-commit run, ensuring CI and pre-commit use the same pinned ruff version. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent 63f89b3 commit 3e4fd59

26 files changed

Lines changed: 41 additions & 89 deletions

.github/workflows/main.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ jobs:
7878
- name: Check out source code
7979
uses: actions/checkout@v4
8080

81-
- name: Install ruff
82-
run: pip install ruff
81+
- name: Set up Python
82+
uses: actions/setup-python@v5
83+
with:
84+
python-version: '3.10'
8385

84-
- name: Ruff lint
85-
run: ruff check .
86+
- name: Install pre-commit
87+
run: pip install pre-commit
8688

87-
- name: Ruff format
88-
run: ruff format --check --diff .
89+
- name: Run pre-commit hooks
90+
run: pre-commit run --all-files --show-diff-on-failure

api/config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from pydantic_settings import BaseSettings
1010

1111

12-
# pylint: disable=too-few-public-methods
1312
class AuthSettings(BaseSettings):
1413
"""Authentication settings"""
1514

@@ -21,7 +20,6 @@ class AuthSettings(BaseSettings):
2120
public_base_url: str | None = None
2221

2322

24-
# pylint: disable=too-few-public-methods
2523
class PubSubSettings(BaseSettings):
2624
"""Pub/Sub settings loaded from the environment"""
2725

@@ -35,7 +33,6 @@ class PubSubSettings(BaseSettings):
3533
subscriber_state_ttl_days: int = 30 # Cleanup unused subscriber states
3634

3735

38-
# pylint: disable=too-few-public-methods
3936
class EmailSettings(BaseSettings):
4037
"""Email settings"""
4138

api/email_sender.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .config import EmailSettings
1818

1919

20-
class EmailSender: # pylint: disable=too-few-public-methods
20+
class EmailSender:
2121
"""Class to send email report using SMTP"""
2222

2323
def __init__(self):

api/main.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
# Author: Jeny Sadadia <jeny.sadadia@collabora.com>
66
# Author: Denys Fedoryshchenko <denys.f@collabora.com>
77

8-
# pylint: disable=unused-argument,global-statement,too-many-lines
9-
108
"""KernelCI API main module"""
119

1210
import asyncio
@@ -120,7 +118,7 @@ def _validate_startup_environment():
120118

121119

122120
@asynccontextmanager
123-
async def lifespan(app: FastAPI): # pylint: disable=redefined-outer-name
121+
async def lifespan(app: FastAPI):
124122
"""Lifespan functions for startup and shutdown events"""
125123
await pubsub_startup()
126124
await create_indexes()
@@ -139,7 +137,7 @@ async def lifespan(app: FastAPI): # pylint: disable=redefined-outer-name
139137
app = FastAPI(lifespan=lifespan, debug=True, docs_url=None, redoc_url=None)
140138
db = Database(service=os.getenv("MONGO_SERVICE", DEFAULT_MONGO_SERVICE))
141139
auth = Authentication(token_url="user/login")
142-
pubsub = None # pylint: disable=invalid-name
140+
pubsub = None
143141

144142
auth_backend = auth.get_user_authentication_backend()
145143
fastapi_users_instance = FastAPIUsers[User, PydanticObjectId](
@@ -151,7 +149,7 @@ async def lifespan(app: FastAPI): # pylint: disable=redefined-outer-name
151149

152150
async def pubsub_startup():
153151
"""Startup event handler to create Pub/Sub object"""
154-
global pubsub # pylint: disable=invalid-name
152+
global pubsub
155153
pubsub = await PubSub.create()
156154

157155

@@ -557,7 +555,7 @@ async def invite_user(
557555
invite_url,
558556
)
559557
email_sent = True
560-
except Exception as exc: # pylint: disable=broad-exception-caught
558+
except Exception as exc:
561559
print(f"Failed to send invite email: {exc}")
562560

563561
return UserInviteResponse(
@@ -640,7 +638,7 @@ async def accept_invite(accept: InviteAcceptRequest):
640638

641639
try:
642640
await user_manager.send_invite_accepted_email(updated_user)
643-
except Exception as exc: # pylint: disable=broad-exception-caught
641+
except Exception as exc:
644642
print(f"Failed to send invite accepted email: {exc}")
645643
return updated_user
646644

api/models.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
# Copyright (C) 2023 Collabora Limited
44
# Author: Jeny Sadadia <jeny.sadadia@collabora.com>
55

6-
# Disable flag as user models don't require any public methods
7-
# at the moment
8-
# pylint: disable=too-few-public-methods
9-
10-
# pylint: disable=no-name-in-module
11-
126
"""Server-side model definitions"""
137

148
from datetime import datetime
@@ -120,7 +114,7 @@ class UserGroupCreateRequest(BaseModel):
120114

121115
class User(
122116
BeanieBaseUser,
123-
Document, # pylint: disable=too-many-ancestors
117+
Document,
124118
DatabaseModel,
125119
):
126120
"""API User model"""
@@ -131,7 +125,7 @@ class User(
131125
)
132126

133127
@field_validator("groups")
134-
def validate_groups(cls, groups): # pylint: disable=no-self-argument
128+
def validate_groups(cls, groups):
135129
"""Unique group constraint"""
136130
unique_names = {group.name for group in groups}
137131
if len(unique_names) != len(groups):
@@ -159,7 +153,7 @@ class UserRead(schemas.BaseUser[PydanticObjectId], ModelId):
159153
groups: List[UserGroup] = Field(default=[])
160154

161155
@field_validator("groups")
162-
def validate_groups(cls, groups): # pylint: disable=no-self-argument
156+
def validate_groups(cls, groups):
163157
"""Unique group constraint"""
164158
unique_names = {group.name for group in groups}
165159
if len(unique_names) != len(groups):
@@ -174,7 +168,7 @@ class UserCreateRequest(schemas.BaseUserCreate):
174168
groups: List[str] = Field(default=[])
175169

176170
@field_validator("groups")
177-
def validate_groups(cls, groups): # pylint: disable=no-self-argument
171+
def validate_groups(cls, groups):
178172
"""Unique group constraint"""
179173
unique_names = set(groups)
180174
if len(unique_names) != len(groups):
@@ -189,7 +183,7 @@ class UserCreate(schemas.BaseUserCreate):
189183
groups: List[UserGroup] = Field(default=[])
190184

191185
@field_validator("groups")
192-
def validate_groups(cls, groups): # pylint: disable=no-self-argument
186+
def validate_groups(cls, groups):
193187
"""Unique group constraint"""
194188
unique_names = {group.name for group in groups}
195189
if len(unique_names) != len(groups):
@@ -206,7 +200,7 @@ class UserUpdateRequest(schemas.BaseUserUpdate):
206200
groups: List[str] = Field(default=[])
207201

208202
@field_validator("groups")
209-
def validate_groups(cls, groups): # pylint: disable=no-self-argument
203+
def validate_groups(cls, groups):
210204
"""Unique group constraint"""
211205
unique_names = set(groups)
212206
if len(unique_names) != len(groups):
@@ -223,7 +217,7 @@ class UserUpdate(schemas.BaseUserUpdate):
223217
groups: List[UserGroup] = Field(default=[])
224218

225219
@field_validator("groups")
226-
def validate_groups(cls, groups): # pylint: disable=no-self-argument
220+
def validate_groups(cls, groups):
227221
"""Unique group constraint"""
228222
unique_names = {group.name for group in groups}
229223
if len(unique_names) != len(groups):
@@ -246,7 +240,7 @@ class UserInviteRequest(BaseModel):
246240
resend_if_exists: bool = False
247241

248242
@field_validator("groups")
249-
def validate_groups(cls, groups): # pylint: disable=no-self-argument
243+
def validate_groups(cls, groups):
250244
"""Unique group constraint"""
251245
unique_names = set(groups)
252246
if len(unique_names) != len(groups):

api/pubsub_mongo.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Copyright (C) 2025 Collabora Limited
44
# Author: Denys Fedoryshchenko <denys.f@collabora.com>
55

6-
# pylint: disable=duplicate-code
76
# Note: This module intentionally shares interface code with pubsub.py
87
# as both implement the same PubSub API contract
98

@@ -35,7 +34,7 @@
3534
logger = logging.getLogger(__name__)
3635

3736

38-
class PubSub: # pylint: disable=too-many-instance-attributes
37+
class PubSub:
3938
"""Hybrid Pub/Sub implementation with MongoDB durability
4039
4140
Supports two modes:
@@ -328,7 +327,6 @@ def _eventhistory_to_cloudevent(self, event: Dict) -> str:
328327
ce = CloudEvent(attributes=attributes, data=event.get("data", {}))
329328
return to_json(ce).decode("utf-8")
330329

331-
# pylint: disable=too-many-arguments
332330
async def _get_missed_events(
333331
self,
334332
channel: str,
@@ -410,7 +408,6 @@ async def subscribe(
410408

411409
return sub
412410

413-
# pylint: disable=too-many-arguments
414411
async def _setup_durable_subscription(
415412
self,
416413
sub_id: int,

tests/e2e_tests/listen_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def create_listen_task(test_async_client, subscription_id):
2323
listen_path,
2424
headers={
2525
"Accept": "application/json",
26-
"Authorization": f"Bearer {pytest.BEARER_TOKEN}", # pylint: disable=no-member
26+
"Authorization": f"Bearer {pytest.BEARER_TOKEN}",
2727
},
2828
)
2929
)

tests/e2e_tests/test_node_handler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def create_node(test_async_client, node):
2424
"node",
2525
headers={
2626
"Accept": "application/json",
27-
"Authorization": f"Bearer {pytest.BEARER_TOKEN}", # pylint: disable=no-member
27+
"Authorization": f"Bearer {pytest.BEARER_TOKEN}",
2828
},
2929
data=json.dumps(node),
3030
)
@@ -44,7 +44,7 @@ async def get_node_by_id(test_async_client, node_id):
4444
f"node/{node_id}",
4545
headers={
4646
"Accept": "application/json",
47-
"Authorization": f"Bearer {pytest.BEARER_TOKEN}", # pylint: disable=no-member
47+
"Authorization": f"Bearer {pytest.BEARER_TOKEN}",
4848
},
4949
)
5050
assert response.status_code == 200
@@ -65,7 +65,7 @@ async def get_node_by_attribute(test_async_client, params):
6565
params=params,
6666
headers={
6767
"Accept": "application/json",
68-
"Authorization": f"Bearer {pytest.BEARER_TOKEN}", # pylint: disable=no-member
68+
"Authorization": f"Bearer {pytest.BEARER_TOKEN}",
6969
},
7070
)
7171
assert response.status_code == 200
@@ -85,7 +85,7 @@ async def update_node(test_async_client, node):
8585
f"node/{node['id']}",
8686
headers={
8787
"Accept": "application/json",
88-
"Authorization": f"Bearer {pytest.BEARER_TOKEN}", # pylint: disable=no-member
88+
"Authorization": f"Bearer {pytest.BEARER_TOKEN}",
8989
},
9090
data=json.dumps(node),
9191
)
@@ -104,7 +104,7 @@ async def patch_node(test_async_client, node_id, patch_data):
104104
f"node/{node_id}",
105105
headers={
106106
"Accept": "application/json",
107-
"Authorization": f"Bearer {pytest.BEARER_TOKEN}", # pylint: disable=no-member
107+
"Authorization": f"Bearer {pytest.BEARER_TOKEN}",
108108
},
109109
data=json.dumps(patch_data),
110110
)

tests/e2e_tests/test_password_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def test_password_endpoint(test_async_client):
2828
"user/me",
2929
headers={
3030
"Accept": "application/json",
31-
"Authorization": f"Bearer {pytest.BEARER_TOKEN}", # pylint: disable=no-member
31+
"Authorization": f"Bearer {pytest.BEARER_TOKEN}",
3232
},
3333
data=json.dumps({"password": "foo"}),
3434
)

tests/e2e_tests/test_pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def test_node_pipeline(test_async_client):
4545
# Create Task to listen pubsub event on 'node' channel
4646
task_listen = create_listen_task(
4747
test_async_client, pytest.node_channel_subscription_id
48-
) # pylint: disable=no-member
48+
)
4949

5050
# Create a node
5151
node = {
@@ -94,7 +94,7 @@ async def test_node_pipeline(test_async_client):
9494
# Create Task to listen 'updated' event on 'node' channel
9595
task_listen = create_listen_task(
9696
test_async_client, pytest.node_channel_subscription_id
97-
) # pylint: disable=no-member
97+
)
9898

9999
# Update node.state
100100
node.update({"state": "done"})

0 commit comments

Comments
 (0)