Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check
name: check
on:
push:
branches:
Expand Down Expand Up @@ -27,3 +27,24 @@ jobs:

- name: Run format check
run: uv run ruff format --check

lint:
runs-on: ubuntu-latest
name: lint
steps:
- name: Check out repository
uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.8"

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Install the project
run: uv sync --dev

- name: Run lint check
run: uv run ruff check
1 change: 0 additions & 1 deletion nats-server/src/nats/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import os
import re
import socket
import tempfile
from typing import Self

# Set up logging
Expand Down
3 changes: 2 additions & 1 deletion nats/examples/advanced.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio

import nats
from nats.errors import NoServersError, TimeoutError

import nats


async def main():
async def disconnected_cb():
Expand Down
5 changes: 3 additions & 2 deletions nats/examples/basic.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import asyncio

import nats
from common import args
from nats.errors import TimeoutError

import nats


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

async def help_request(msg):
Expand Down
5 changes: 3 additions & 2 deletions nats/examples/clustered.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import asyncio
from datetime import datetime

import nats
from nats.aio.errors import ErrConnectionClosed, ErrNoServers, ErrTimeout

import nats


async def run():
# Setup pool of servers from a NATS cluster.
Expand Down Expand Up @@ -66,7 +67,7 @@ async def subscribe_handler(msg):
try:
await nc.publish(f"help.{i}", b"A")
await nc.flush(0.500)
except ErrConnectionClosed as e:
except ErrConnectionClosed:
print("Connection closed prematurely.")
break
except ErrTimeout as e:
Expand Down
3 changes: 2 additions & 1 deletion nats/examples/connect.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio

import nats
from common import args

import nats


async def main():
async def disconnected_cb():
Expand Down
3 changes: 2 additions & 1 deletion nats/examples/context-manager.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio

import nats
from common import args

import nats


async def main():
is_done = asyncio.Future()
Expand Down
3 changes: 2 additions & 1 deletion nats/examples/jetstream.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio

import nats
from nats.errors import TimeoutError

import nats


async def main():
nc = await nats.connect("localhost")
Expand Down
3 changes: 2 additions & 1 deletion nats/examples/micro/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import contextlib
import signal

import nats
import nats.micro

import nats


async def echo(req) -> None:
"""Echo the request data back to the client."""
Expand Down
3 changes: 2 additions & 1 deletion nats/examples/publish.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio

import nats
from common import args

import nats


async def main():
arguments, _ = args.get_args("Run a publish example.", "Usage: python examples/publish.py")
Expand Down
16 changes: 9 additions & 7 deletions nats/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import urllib
from unittest import mock

import nats
import nats.errors
import pytest
from nats.aio.client import Client as NATS, ServerVersion, __version__
from nats.aio.client import Client as NATS
from nats.aio.client import ServerVersion, __version__

import nats
from tests.utils import (
ClusteringDiscoveryAuthTestCase,
ClusteringTestCase,
Expand Down Expand Up @@ -669,9 +671,9 @@ async def next_msg():

# FIXME: This message would be lost because cannot
# reuse the future from the iterator that timed out.
await nc.publish(f"tests.2", b"bar")
await nc.publish("tests.2", b"bar")

await nc.publish(f"tests.3", b"bar")
await nc.publish("tests.3", b"bar")
await nc.flush()

# FIXME: this test is flaky
Expand Down Expand Up @@ -717,8 +719,8 @@ async def test_subscribe_next_msg(self):
await sub.next_msg(timeout=0.5)

# Send again a couple of messages.
await nc.publish(f"tests.2", b"bar")
await nc.publish(f"tests.3", b"bar")
await nc.publish("tests.2", b"bar")
await nc.publish("tests.3", b"bar")
await nc.flush()
msg = await sub.next_msg()
self.assertEqual("tests.2", msg.subject)
Expand Down Expand Up @@ -2809,7 +2811,7 @@ async def test_drain_cancelled_errors_raised(self):
async def cb(msg):
await asyncio.sleep(20)

sub = await nc.subscribe(f"test.sub", cb=cb)
sub = await nc.subscribe("test.sub", cb=cb)
await nc.publish("test.sub")
await nc.publish("test.sub")
await asyncio.sleep(0.1)
Expand Down
1 change: 1 addition & 0 deletions nats/tests/test_client_async_await.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from nats.aio.client import Client as NATS
from nats.errors import SlowConsumerError, TimeoutError

from tests.utils import SingleServerTestCase, async_test


Expand Down
4 changes: 3 additions & 1 deletion nats/tests/test_client_nkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
except ModuleNotFoundError:
nkeys_installed = False

from nats.aio.client import Client as NATS, RawCredentials
from nats.aio.client import Client as NATS
from nats.aio.client import RawCredentials
from nats.aio.errors import *
from nats.errors import *

from tests.utils import (
NkeysServerTestCase,
TrustedServerTestCase,
Expand Down
3 changes: 2 additions & 1 deletion nats/tests/test_client_v2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import unittest

import nats
from nats.aio.errors import *

import nats
from tests.utils import *


Expand Down
3 changes: 2 additions & 1 deletion nats/tests/test_client_websocket.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import asyncio
import unittest

import nats
import pytest
from nats.aio.errors import *

import nats
from tests.utils import *

try:
Expand Down
3 changes: 2 additions & 1 deletion nats/tests/test_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import Any, Dict, List, Optional
from unittest import TestCase, skipIf

import nats
from nats.aio.subscription import Subscription
from nats.micro.request import ServiceError
from nats.micro.service import (
Expand All @@ -18,6 +17,8 @@
ServiceConfig,
)

import nats

from .utils import *

try:
Expand Down
Loading
Loading