Skip to content

Commit 1d38f9b

Browse files
authored
Use ruff for linting (#742)
Signed-off-by: Casper Beyer <[email protected]>
1 parent 3fc3f79 commit 1d38f9b

20 files changed

+91
-45
lines changed

.github/workflows/check.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Check
1+
name: check
22
on:
33
push:
44
branches:
@@ -27,3 +27,24 @@ jobs:
2727

2828
- name: Run format check
2929
run: uv run ruff format --check
30+
31+
lint:
32+
runs-on: ubuntu-latest
33+
name: lint
34+
steps:
35+
- name: Check out repository
36+
uses: actions/checkout@v5
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v6
40+
with:
41+
python-version: "3.8"
42+
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v6
45+
46+
- name: Install the project
47+
run: uv sync --dev
48+
49+
- name: Run lint check
50+
run: uv run ruff check

nats-server/src/nats/server/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import os
2525
import re
2626
import socket
27-
import tempfile
2827
from typing import Self
2928

3029
# Set up logging

nats/examples/advanced.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import asyncio
22

3-
import nats
43
from nats.errors import NoServersError, TimeoutError
54

5+
import nats
6+
67

78
async def main():
89
async def disconnected_cb():

nats/examples/basic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import asyncio
22

3-
import nats
43
from common import args
54
from nats.errors import TimeoutError
65

6+
import nats
7+
78

89
async def main():
910
arguments, _ = args.get_args("Run a basic example.")
@@ -33,7 +34,7 @@ async def message_handler(msg):
3334
async for msg in sub.messages:
3435
print(f"Received a message on '{msg.subject} {msg.reply}': {msg.data.decode()}")
3536
await sub.unsubscribe()
36-
except Exception as e:
37+
except Exception:
3738
pass
3839

3940
async def help_request(msg):

nats/examples/clustered.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import asyncio
22
from datetime import datetime
33

4-
import nats
54
from nats.aio.errors import ErrConnectionClosed, ErrNoServers, ErrTimeout
65

6+
import nats
7+
78

89
async def run():
910
# Setup pool of servers from a NATS cluster.
@@ -66,7 +67,7 @@ async def subscribe_handler(msg):
6667
try:
6768
await nc.publish(f"help.{i}", b"A")
6869
await nc.flush(0.500)
69-
except ErrConnectionClosed as e:
70+
except ErrConnectionClosed:
7071
print("Connection closed prematurely.")
7172
break
7273
except ErrTimeout as e:

nats/examples/connect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import asyncio
22

3-
import nats
43
from common import args
54

5+
import nats
6+
67

78
async def main():
89
async def disconnected_cb():

nats/examples/context-manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import asyncio
22

3-
import nats
43
from common import args
54

5+
import nats
6+
67

78
async def main():
89
is_done = asyncio.Future()

nats/examples/jetstream.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import asyncio
22

3-
import nats
43
from nats.errors import TimeoutError
54

5+
import nats
6+
67

78
async def main():
89
nc = await nats.connect("localhost")

nats/examples/micro/service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import contextlib
33
import signal
44

5-
import nats
65
import nats.micro
76

7+
import nats
8+
89

910
async def echo(req) -> None:
1011
"""Echo the request data back to the client."""

nats/examples/publish.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import asyncio
22

3-
import nats
43
from common import args
54

5+
import nats
6+
67

78
async def main():
89
arguments, _ = args.get_args("Run a publish example.", "Usage: python examples/publish.py")

0 commit comments

Comments
 (0)