Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/labthings_fastapi/utilities/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
if remove_first_positional_arg:
name, parameter = next(iter((parameters.items()))) # get the first parameter
if parameter.kind in (Parameter.KEYWORD_ONLY, Parameter.VAR_KEYWORD):
raise ValueError("Can't remove first positional argument: there is none.")

Check warning on line 87 in src/labthings_fastapi/utilities/introspection.py

View workflow job for this annotation

GitHub Actions / coverage

87 line is not covered with tests
del parameters[name]

# Raise errors if positional-only or variable positional args are present
Expand All @@ -94,7 +94,7 @@
"which is not supported."
)
if any(p.kind == Parameter.POSITIONAL_ONLY for p in parameters.values()):
raise TypeError(

Check warning on line 97 in src/labthings_fastapi/utilities/introspection.py

View workflow job for this annotation

GitHub Actions / coverage

97 line is not covered with tests
f"{func.__name__} has positional-only arguments which are not supported."
)

Expand All @@ -117,7 +117,7 @@
fields[name] = (p_type, default)
model = create_model( # type: ignore[call-overload]
f"{func.__name__}_input",
model_config=ConfigDict(extra="allow" if takes_v_kwargs else "forbid"),
__config__=ConfigDict(extra="allow" if takes_v_kwargs else "forbid"),
**fields,
)
# If there are no fields, we use a RootModel to allow none as well as {}
Expand Down