Skip to content

Commit 235a7fc

Browse files
committed
Add pre-commit configuration for Ruff linter and formatter; update development dependencies in pyproject.toml and uv.lock; minor formatting adjustments in CLI and proxy modules.
1 parent 2b1956d commit 235a7fc

File tree

6 files changed

+158
-8
lines changed

6 files changed

+158
-8
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.8.1
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
types_or: [ python, pyi ]
9+
args: [ --fix ]
10+
# Run the formatter.
11+
- id: ruff-format
12+
types_or: [ python, pyi ]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ omproxy = "omproxy.cli:main"
1717

1818
[dependency-groups]
1919
dev = [
20+
"pre-commit>=4.0.1",
2021
"pytest>=8.3.4",
2122
"pytest-asyncio>=0.24.0",
2223
"ruff>=0.8.2",

src/omproxy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.0"
1+
__version__ = "0.1.0"

src/omproxy/cli.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,23 @@
1010

1111

1212
def main():
13-
parser = argparse.ArgumentParser(description="Bidirectional proxy for subprocess communication")
14-
parser.add_argument("-v", "--verbose", action="store_true", help="Enable debug logging")
15-
parser.add_argument("command", nargs="+", help="Command to run with optional arguments")
13+
parser = argparse.ArgumentParser(
14+
description="Bidirectional proxy for subprocess communication"
15+
)
16+
parser.add_argument(
17+
"-v", "--verbose", action="store_true", help="Enable debug logging"
18+
)
19+
parser.add_argument(
20+
"command", nargs="+", help="Command to run with optional arguments"
21+
)
1622
args = parser.parse_args()
1723

1824
# Configure logging
1925
logfire.configure(service_name="iod_proxy", service_version="0.1.0", console=False)
2026
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)
2127

2228
logfire.info("starting_proxy", command=args.command)
29+
2330
async def run_proxy():
2431
async with Proxy(
2532
lambda line: logfire.info("on_stdin_cb", line=line),

src/omproxy/proxy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
173173
# First close the anyio streams (which will close their underlying file objects)
174174
await self.process_stdin.aclose()
175175
await self.process_stdout.aclose()
176-
176+
177177
# Close memory streams (both ends)
178178
await self.read_stream_writer.aclose()
179179
await self.read_stream.aclose()
180180
await self.write_stream.aclose()
181181
await self.write_stream_reader.aclose()
182-
182+
183183
# Close our unused raw file descriptors
184-
os.close(self.stdin_read_fd) # Close subprocess's reading end
185-
os.close(self.stdout_write_fd) # Close subprocess's writing end
184+
os.close(self.stdin_read_fd) # Close subprocess's reading end
185+
os.close(self.stdout_write_fd) # Close subprocess's writing end

0 commit comments

Comments
 (0)