5
5
import sys
6
6
import warnings
7
7
from pathlib import Path
8
- from typing import Annotated , Optional
8
+ from typing import Annotated
9
9
10
10
import typer
11
11
import uvicorn
35
35
@app_cli .command ()
36
36
def new (
37
37
name : Annotated [
38
- Optional [ str ] ,
38
+ str | None ,
39
39
typer .Argument (
40
40
help = "The name of the folder to create" ,
41
41
),
42
42
] = None ,
43
43
* ,
44
44
package : Annotated [
45
- Optional [ list [str ]] ,
45
+ list [str ] | None ,
46
46
typer .Option (help = "Packages to seed the project with" ),
47
47
] = None ,
48
48
pip : Annotated [
49
- Optional [ bool ] ,
49
+ bool | None ,
50
50
typer .Option (
51
51
"--pip/--no-pip" ,
52
52
help = "Pip install the template(s) as editable dependencies" ,
@@ -131,24 +131,24 @@ def new(
131
131
@app_cli .command ()
132
132
def add (
133
133
dependencies : Annotated [
134
- Optional [ list [str ]] ,
134
+ list [str ] | None ,
135
135
typer .Argument (help = "The dependency to add" ),
136
136
] = None ,
137
137
* ,
138
138
api_path : Annotated [
139
- Optional [ list [str ]] ,
139
+ list [str ] | None ,
140
140
typer .Option (help = "API paths to add" ),
141
141
] = None ,
142
142
project_dir : Annotated [
143
- Optional [ Path ] ,
143
+ Path | None ,
144
144
typer .Option (help = "The project directory" ),
145
145
] = None ,
146
146
repo : Annotated [
147
- Optional [ list [str ]] ,
147
+ list [str ] | None ,
148
148
typer .Option (help = "Install templates from a specific github repo instead" ),
149
149
] = None ,
150
150
branch : Annotated [
151
- Optional [ list [str ]] ,
151
+ list [str ] | None ,
152
152
typer .Option (help = "Install templates from a specific branch" ),
153
153
] = None ,
154
154
pip : Annotated [
@@ -191,7 +191,7 @@ def add(
191
191
)
192
192
193
193
# group by repo/ref
194
- grouped : dict [tuple [str , Optional [ str ] ], list [DependencySource ]] = {}
194
+ grouped : dict [tuple [str , str | None ], list [DependencySource ]] = {}
195
195
for dep in parsed_deps :
196
196
key_tup = (dep ["git" ], dep ["ref" ])
197
197
lst = grouped .get (key_tup , [])
@@ -243,7 +243,7 @@ def add(
243
243
try :
244
244
add_dependencies_to_pyproject_toml (
245
245
project_root / "pyproject.toml" ,
246
- zip (installed_destination_names , installed_destination_paths ),
246
+ zip (installed_destination_names , installed_destination_paths , strict = False ),
247
247
)
248
248
except Exception :
249
249
# Can fail if user modified/removed pyproject.toml
@@ -281,11 +281,11 @@ def add(
281
281
282
282
imports = [
283
283
f"from { e ['module' ]} import { e ['attr' ]} as { name } "
284
- for e , name in zip (installed_exports , chain_names )
284
+ for e , name in zip (installed_exports , chain_names , strict = False )
285
285
]
286
286
routes = [
287
287
f'add_routes(app, { name } , path="{ path } ")'
288
- for name , path in zip (chain_names , api_paths )
288
+ for name , path in zip (chain_names , api_paths , strict = False )
289
289
]
290
290
291
291
t = (
@@ -310,7 +310,7 @@ def remove(
310
310
api_paths : Annotated [list [str ], typer .Argument (help = "The API paths to remove" )],
311
311
* ,
312
312
project_dir : Annotated [
313
- Optional [ Path ] ,
313
+ Path | None ,
314
314
typer .Option (help = "The project directory" ),
315
315
] = None ,
316
316
) -> None :
@@ -349,15 +349,15 @@ def remove(
349
349
def serve (
350
350
* ,
351
351
port : Annotated [
352
- Optional [ int ] ,
352
+ int | None ,
353
353
typer .Option (help = "The port to run the server on" ),
354
354
] = None ,
355
355
host : Annotated [
356
- Optional [ str ] ,
356
+ str | None ,
357
357
typer .Option (help = "The host to run the server on" ),
358
358
] = None ,
359
359
app : Annotated [
360
- Optional [ str ] ,
360
+ str | None ,
361
361
typer .Option (help = "The app to run, e.g. `app.server:app`" ),
362
362
] = None ,
363
363
) -> None :
0 commit comments