diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c6175e0..99bb98bb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: hooks: - id: check-yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.2 + rev: v0.3.2 hooks: - id: ruff args: [ --fix ] @@ -26,7 +26,7 @@ repos: args: ["--ignore", "D001"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.8.0' + rev: 'v1.9.0' hooks: - id: mypy additional_dependencies: diff --git a/doc/example/popen_read_multiple.py b/doc/example/popen_read_multiple.py index 571faf34..43d0ed04 100644 --- a/doc/example/popen_read_multiple.py +++ b/doc/example/popen_read_multiple.py @@ -3,6 +3,7 @@ reading results from possibly blocking code running in sub processes. """ + import execnet NUM_PROCESSES = 5 diff --git a/doc/example/redirect_remote_output.py b/doc/example/redirect_remote_output.py index d5fb43e0..0fea4ebb 100644 --- a/doc/example/redirect_remote_output.py +++ b/doc/example/redirect_remote_output.py @@ -7,6 +7,7 @@ - setting a callback for receiving channel data """ + import execnet gw = execnet.makegateway() diff --git a/doc/example/svn-sync-repo.py b/doc/example/svn-sync-repo.py index 24e7bd58..4377dc3f 100644 --- a/doc/example/svn-sync-repo.py +++ b/doc/example/svn-sync-repo.py @@ -5,6 +5,7 @@ uses execnet. """ + import os import pathlib import subprocess diff --git a/doc/example/sysinfo.py b/doc/example/sysinfo.py index f13d1199..b3fa2d5e 100644 --- a/doc/example/sysinfo.py +++ b/doc/example/sysinfo.py @@ -5,6 +5,7 @@ (c) Holger Krekel, MIT license """ + import optparse import re import sys diff --git a/src/execnet/__init__.py b/src/execnet/__init__.py index d22eb1af..a266bded 100644 --- a/src/execnet/__init__.py +++ b/src/execnet/__init__.py @@ -6,6 +6,7 @@ (c) 2012, Holger Krekel and others """ + from ._version import version as __version__ from .gateway_base import DataFormatError from .gateway_base import RemoteError diff --git a/src/execnet/gateway.py b/src/execnet/gateway.py index c7a64153..ec197398 100644 --- a/src/execnet/gateway.py +++ b/src/execnet/gateway.py @@ -2,6 +2,7 @@ gateway code for initiating popen, socket and ssh connections. (c) 2004-2013, Holger Krekel and others """ + from __future__ import annotations import inspect @@ -48,9 +49,7 @@ def __repr__(self) -> str: except AttributeError: r = "uninitialized" i = "no" - return "<{} id={!r} {}, {} model, {} active channels>".format( - self.__class__.__name__, self.id, r, self.execmodel.backend, i - ) + return f"<{self.__class__.__name__} id={self.id!r} {r}, {self.execmodel.backend} model, {i} active channels>" def exit(self) -> None: """trigger gateway exit. Defer waiting for finishing @@ -166,8 +165,7 @@ def __repr__(self) -> str: if TYPE_CHECKING: - def __getattr__(self, name: str) -> Any: - ... + def __getattr__(self, name: str) -> Any: ... RemoteStatus = RInfo diff --git a/src/execnet/gateway_base.py b/src/execnet/gateway_base.py index 494a6839..d88e6585 100644 --- a/src/execnet/gateway_base.py +++ b/src/execnet/gateway_base.py @@ -11,6 +11,7 @@ - Ronny Pfannschmidt - many others """ + from __future__ import annotations import abc @@ -32,51 +33,39 @@ class WriteIO(Protocol): - def write(self, data: bytes, /) -> None: - ... + def write(self, data: bytes, /) -> None: ... class ReadIO(Protocol): - def read(self, numbytes: int, /) -> bytes: - ... + def read(self, numbytes: int, /) -> bytes: ... class IO(Protocol): execmodel: ExecModel - def read(self, numbytes: int, /) -> bytes: - ... + def read(self, numbytes: int, /) -> bytes: ... - def write(self, data: bytes, /) -> None: - ... + def write(self, data: bytes, /) -> None: ... - def close_read(self) -> None: - ... + def close_read(self) -> None: ... - def close_write(self) -> None: - ... + def close_write(self) -> None: ... - def wait(self) -> int | None: - ... + def wait(self) -> int | None: ... - def kill(self) -> None: - ... + def kill(self) -> None: ... class Event(Protocol): """Protocol for types which look like threading.Event.""" - def is_set(self) -> bool: - ... + def is_set(self) -> bool: ... - def set(self) -> None: - ... + def set(self) -> None: ... - def clear(self) -> None: - ... + def clear(self) -> None: ... - def wait(self, timeout: float | None = None) -> bool: - ... + def wait(self, timeout: float | None = None) -> bool: ... class ExecModel(metaclass=abc.ABCMeta): @@ -973,9 +962,9 @@ def reconfigure( class ChannelFactory: def __init__(self, gateway: BaseGateway, startcount: int = 1) -> None: - self._channels: weakref.WeakValueDictionary[ - int, Channel - ] = weakref.WeakValueDictionary() + self._channels: weakref.WeakValueDictionary[int, Channel] = ( + weakref.WeakValueDictionary() + ) # Channel ID => (callback, end marker, strconfig) self._callbacks: dict[ int, tuple[Callable[[Any], Any], object, tuple[bool, bool]] diff --git a/src/execnet/gateway_bootstrap.py b/src/execnet/gateway_bootstrap.py index 6ea7113b..165e8cad 100644 --- a/src/execnet/gateway_bootstrap.py +++ b/src/execnet/gateway_bootstrap.py @@ -1,6 +1,7 @@ """ code to initialize the remote side of a gateway once the io is created """ + from __future__ import annotations import inspect diff --git a/src/execnet/gateway_io.py b/src/execnet/gateway_io.py index 37b00de0..a29fcc78 100644 --- a/src/execnet/gateway_io.py +++ b/src/execnet/gateway_io.py @@ -3,6 +3,7 @@ creates io instances used for gateway io """ + from __future__ import annotations import shlex diff --git a/src/execnet/multi.py b/src/execnet/multi.py index 6ac76884..2b447d57 100644 --- a/src/execnet/multi.py +++ b/src/execnet/multi.py @@ -3,6 +3,7 @@ (c) 2008-2014, Holger Krekel and others """ + from __future__ import annotations import atexit diff --git a/src/execnet/rsync.py b/src/execnet/rsync.py index 648021d9..6e14fef5 100644 --- a/src/execnet/rsync.py +++ b/src/execnet/rsync.py @@ -3,6 +3,7 @@ (c) 2006-2009, Armin Rigo, Holger Krekel, Maciej Fijalkowski """ + from __future__ import annotations import os diff --git a/src/execnet/rsync_remote.py b/src/execnet/rsync_remote.py index 24dccc9c..b560df75 100644 --- a/src/execnet/rsync_remote.py +++ b/src/execnet/rsync_remote.py @@ -1,6 +1,7 @@ """ (c) 2006-2013, Armin Rigo, Holger Krekel, Maciej Fijalkowski """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/src/execnet/script/quitserver.py b/src/execnet/script/quitserver.py index 1ea3fccd..4c94c383 100644 --- a/src/execnet/script/quitserver.py +++ b/src/execnet/script/quitserver.py @@ -1,8 +1,9 @@ """ - send a "quit" signal to a remote server +send a "quit" signal to a remote server """ + from __future__ import annotations import socket diff --git a/src/execnet/script/shell.py b/src/execnet/script/shell.py index 7f4bc02b..569d4042 100644 --- a/src/execnet/script/shell.py +++ b/src/execnet/script/shell.py @@ -4,6 +4,7 @@ for injection into startserver.py """ + import os import select import socket diff --git a/src/execnet/script/socketserver.py b/src/execnet/script/socketserver.py index 34dfc0a3..b58d1a4c 100644 --- a/src/execnet/script/socketserver.py +++ b/src/execnet/script/socketserver.py @@ -1,14 +1,15 @@ #! /usr/bin/env python """ - start socket based minimal readline exec server +start socket based minimal readline exec server - it can exeuted in 2 modes of operation +it can exeuted in 2 modes of operation - 1. as normal script, that listens for new connections +1. as normal script, that listens for new connections - 2. via existing_gateway.remote_exec (as imported module) +2. via existing_gateway.remote_exec (as imported module) """ + # this part of the program only executes on the server side # from __future__ import annotations diff --git a/src/execnet/script/socketserverservice.py b/src/execnet/script/socketserverservice.py index cc525e94..9c18c12c 100644 --- a/src/execnet/script/socketserverservice.py +++ b/src/execnet/script/socketserverservice.py @@ -5,6 +5,7 @@ python socketserverservice.py register net start ExecNetSocketServer """ + import sys import threading diff --git a/src/execnet/xspec.py b/src/execnet/xspec.py index 5bc437ea..0cbf3de7 100644 --- a/src/execnet/xspec.py +++ b/src/execnet/xspec.py @@ -1,6 +1,7 @@ """ (c) 2008-2013, holger krekel """ + from __future__ import annotations diff --git a/testing/test_channel.py b/testing/test_channel.py index 67039825..f500f117 100644 --- a/testing/test_channel.py +++ b/testing/test_channel.py @@ -1,6 +1,7 @@ """ mostly functional tests of gateways. """ + from __future__ import annotations import time diff --git a/testing/test_gateway.py b/testing/test_gateway.py index e507a935..4291404e 100644 --- a/testing/test_gateway.py +++ b/testing/test_gateway.py @@ -1,6 +1,7 @@ """ mostly functional tests of gateways. """ + from __future__ import annotations import os diff --git a/testing/test_multi.py b/testing/test_multi.py index 445b3f15..edc93037 100644 --- a/testing/test_multi.py +++ b/testing/test_multi.py @@ -1,6 +1,7 @@ """ - tests for multi channels and gateway Groups +tests for multi channels and gateway Groups """ + from __future__ import annotations import gc