|
1 | 1 | import json |
2 | 2 | import re |
| 3 | +import subprocess |
3 | 4 | from pathlib import Path |
4 | 5 | from textwrap import dedent |
5 | 6 | from typing import ( |
|
16 | 17 | cast, |
17 | 18 | ) |
18 | 19 |
|
19 | | -import black |
20 | 20 | from pydantic import BaseModel, Field, RootModel |
21 | 21 |
|
22 | 22 | from replit_river.codegen.format import reindent |
@@ -831,9 +831,14 @@ def __init__(self, client: river.Client[Any]): |
831 | 831 | exclude_none=True, |
832 | 832 | ) |
833 | 833 | """ |
834 | | - if isinstance( |
835 | | - procedure.input, RiverConcreteType |
836 | | - ) and procedure.input.type not in ["object", "array"]: |
| 834 | + if ( |
| 835 | + ( |
| 836 | + isinstance(procedure.input, RiverConcreteType) |
| 837 | + and procedure.input.type not in ["object", "array"] |
| 838 | + ) |
| 839 | + or isinstance(procedure.input, RiverNotType) |
| 840 | + or procedure.input is None |
| 841 | + ): |
837 | 842 | render_input_method = "lambda x: x" |
838 | 843 |
|
839 | 844 | assert ( |
@@ -1077,11 +1082,10 @@ def schema_to_river_client_codegen( |
1077 | 1082 | module_path.parent.mkdir(mode=0o755, parents=True, exist_ok=True) |
1078 | 1083 | with open(module_path, "w") as f: |
1079 | 1084 | try: |
1080 | | - f.write( |
1081 | | - black.format_str( |
1082 | | - contents, mode=black.FileMode(string_normalization=False) |
1083 | | - ) |
| 1085 | + popen = subprocess.Popen( |
| 1086 | + ["ruff", "format", "-"], stdin=subprocess.PIPE, stdout=f |
1084 | 1087 | ) |
| 1088 | + popen.communicate(contents.encode()) |
1085 | 1089 | except: |
1086 | 1090 | f.write(contents) |
1087 | 1091 | raise |
0 commit comments