Skip to content

Commit 924b6dd

Browse files
CoolCat467A5rocks
andcommitted
Fix several things from review
Co-authored-by: A5rocks <[email protected]>
1 parent d2a4031 commit 924b6dd

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

src/trio/_core/_tests/test_mock_clock.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ async def test_mock_clock_autojump(mock_clock: MockClock) -> None:
9292
mock_clock.autojump_threshold = 0
9393
# if the above line didn't take affect immediately, then this would be
9494
# bad:
95-
await sleep(100000) # noqa: ASYNC116 # not sleep_forever
95+
# ignore ASYNC116, not sleep_forever, trying to test a large but finite sleep
96+
await sleep(100000) # noqa: ASYNC116
9697

9798

9899
async def test_mock_clock_autojump_interference(mock_clock: MockClock) -> None:

src/trio/_socket.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -682,11 +682,9 @@ async def accept(self) -> tuple[SocketType, AddressFormat]:
682682
async def connect(self, address: AddressFormat) -> None:
683683
raise NotImplementedError
684684

685-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
686685
def recv(__self, __buflen: int, __flags: int = 0) -> Awaitable[bytes]:
687686
raise NotImplementedError
688687

689-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
690688
def recv_into(
691689
__self,
692690
buffer: Buffer,
@@ -695,7 +693,6 @@ def recv_into(
695693
) -> Awaitable[int]:
696694
raise NotImplementedError
697695

698-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
699696
# return type of socket.socket.recvfrom in typeshed is tuple[bytes, Any]
700697
def recvfrom(
701698
__self,
@@ -716,7 +713,7 @@ def recvfrom_into(
716713
if sys.platform != "win32" or (
717714
not TYPE_CHECKING and hasattr(_stdlib_socket.socket, "recvmsg")
718715
):
719-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
716+
720717
def recvmsg(
721718
__self,
722719
__bufsize: int,
@@ -728,7 +725,7 @@ def recvmsg(
728725
if sys.platform != "win32" or (
729726
not TYPE_CHECKING and hasattr(_stdlib_socket.socket, "recvmsg_into")
730727
):
731-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
728+
732729
def recvmsg_into(
733730
__self,
734731
__buffers: Iterable[Buffer],
@@ -737,19 +734,16 @@ def recvmsg_into(
737734
) -> Awaitable[tuple[int, list[tuple[int, int, bytes]], int, Any]]:
738735
raise NotImplementedError
739736

740-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
741737
def send(__self, __bytes: Buffer, __flags: int = 0) -> Awaitable[int]:
742738
raise NotImplementedError
743739

744-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
745740
@overload
746741
async def sendto(
747742
self,
748743
__data: Buffer,
749744
__address: tuple[object, ...] | str | Buffer,
750745
) -> int: ...
751746

752-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
753747
@overload
754748
async def sendto(
755749
self,
@@ -764,7 +758,7 @@ async def sendto(self, *args: Any) -> int:
764758
if sys.platform != "win32" or (
765759
not TYPE_CHECKING and hasattr(_stdlib_socket.socket, "sendmsg")
766760
):
767-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
761+
768762
@_wraps(_stdlib_socket.socket.sendmsg, assigned=(), updated=())
769763
async def sendmsg(
770764
self,
@@ -1144,7 +1138,7 @@ def recv(__self, __buflen: int, __flags: int = 0) -> Awaitable[bytes]: ...
11441138
################################################################
11451139

11461140
if TYPE_CHECKING:
1147-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
1141+
11481142
def recv_into(
11491143
__self,
11501144
buffer: Buffer,
@@ -1162,7 +1156,6 @@ def recv_into(
11621156
################################################################
11631157

11641158
if TYPE_CHECKING:
1165-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
11661159
# return type of socket.socket.recvfrom in typeshed is tuple[bytes, Any]
11671160
def recvfrom(
11681161
__self,
@@ -1201,7 +1194,7 @@ def recvfrom_into(
12011194
not TYPE_CHECKING and hasattr(_stdlib_socket.socket, "recvmsg")
12021195
):
12031196
if TYPE_CHECKING:
1204-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
1197+
12051198
def recvmsg(
12061199
__self,
12071200
__bufsize: int,
@@ -1223,7 +1216,7 @@ def recvmsg(
12231216
not TYPE_CHECKING and hasattr(_stdlib_socket.socket, "recvmsg_into")
12241217
):
12251218
if TYPE_CHECKING:
1226-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
1219+
12271220
def recvmsg_into(
12281221
__self,
12291222
__buffers: Iterable[Buffer],
@@ -1242,7 +1235,7 @@ def recvmsg_into(
12421235
################################################################
12431236

12441237
if TYPE_CHECKING:
1245-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
1238+
12461239
def send(__self, __bytes: Buffer, __flags: int = 0) -> Awaitable[int]: ...
12471240

12481241
send = _make_simple_sock_method_wrapper(
@@ -1254,15 +1247,13 @@ def send(__self, __bytes: Buffer, __flags: int = 0) -> Awaitable[int]: ...
12541247
# sendto
12551248
################################################################
12561249

1257-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
12581250
@overload
12591251
async def sendto(
12601252
self,
12611253
__data: Buffer,
12621254
__address: tuple[object, ...] | str | Buffer,
12631255
) -> int: ...
12641256

1265-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
12661257
@overload
12671258
async def sendto(
12681259
self,
@@ -1293,7 +1284,7 @@ async def sendto(self, *args: Any) -> int:
12931284
if sys.platform != "win32" or (
12941285
not TYPE_CHECKING and hasattr(_stdlib_socket.socket, "sendmsg")
12951286
):
1296-
# argument names with __ used because of typeshed, see comment for recv in _SocketType
1287+
12971288
@_wraps(_stdlib_socket.socket.sendmsg, assigned=(), updated=())
12981289
async def sendmsg(
12991290
self,

src/trio/_tests/test_ssl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,8 @@ async def expect(expected: bytes) -> None:
707707
# Our receive_some() call will get stuck when it hits send_all
708708
async def sleeper_with_slow_send_all(method: str) -> None:
709709
if method == "send_all":
710-
await trio.sleep(100000) # noqa: ASYNC116 # not sleep forever
710+
# ignore ASYNC116, not sleep_forever, trying to test a large but finite sleep
711+
await trio.sleep(100000) # noqa: ASYNC116
711712

712713
# And our wait_send_all_might_not_block call will give it time to get
713714
# stuck, and then start

src/trio/_tools/gen_exports.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ def process(files: Iterable[File], *, do_test: bool) -> None:
302302
print("Generated sources are up to date.")
303303
else:
304304
for new_path, new_source in new_files.items():
305-
Path(new_path).write_text(new_source, encoding="utf-8")
305+
with open(new_path, "w", encoding="utf-8", newline="\n") as fp:
306+
fp.write(new_source)
306307
print("Regenerated sources successfully.")
307308
if not matches_disk:
308309
# With pre-commit integration, show that we edited files.

0 commit comments

Comments
 (0)