Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies = [
"pydantic==2.14.0a1",
"python-json-logger==4.1.0",
"starlette==1.3.1",
"typing-extensions>=4.16.0", # Transitive dependency of pydantic that we force to >=4.16.0 in order to get pickling support for the MISSING sentinel
]

[dependency-groups]
Expand Down Expand Up @@ -48,7 +49,8 @@ tests = [
typing = [
{ include-group = "build" },
{ include-group = "tests" },
"mypy~=2.1.0",
# "mypy~=2.1.0",
"mypy @ git+https://github.com/edgarrmondragon/mypy.git@sentinels-reloaded",
"ty==0.0.55",
"types-PyYAML>=6.0.12.20240808",
"types-requests>=2.32.0",
Expand All @@ -63,6 +65,7 @@ required-version = ">=0.11"
DEP002 = [
"granian", # Not imported, but used as the ASGI server as a uvicorn alternative
"python-json-logger", # Imported dynamically by logging configuration
"typing-extensions", # Transitive dependency of pydantic that we force to >=4.16.0 in order to get pickling support for the MISSING sentinel
]

[tool.ruff]
Expand Down
13 changes: 8 additions & 5 deletions src/hub_api/api/api_v1/endpoints/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import fastapi
import fastapi.responses
from pydantic import BaseModel, ConfigDict, Field
from pydantic.experimental.missing_sentinel import MISSING

from hub_api import dependencies, enums, ids
from hub_api.helpers import compatibility
Expand Down Expand Up @@ -89,14 +90,14 @@ class FindParams(BaseModel):
examples=["tap-github"],
)

type: enums.PluginTypeEnum = Field( # type: ignore[assignment] # ty:ignore[invalid-assignment]
None,
type: enums.PluginTypeEnum | MISSING = Field(
MISSING,
description="The plugin type",
examples=[enums.PluginTypeEnum.extractors],
)

variant: str = Field( # type: ignore[assignment] # ty:ignore[invalid-assignment]
None,
variant: str | MISSING = Field(
MISSING,
description="The optional variant name",
examples=["meltanolabs"],
)
Expand All @@ -115,7 +116,9 @@ async def find_plugin(
hub: dependencies.Hub,
params: Annotated[FindParams, fastapi.Query()],
) -> api_schemas.PluginDetails:
return await hub.find_plugin(plugin_name=params.name, plugin_type=params.type, variant_name=params.variant)
plugin_type = None if params.type is MISSING else params.type
variant_name = None if params.variant is MISSING else params.variant
return await hub.find_plugin(plugin_name=params.name, plugin_type=plugin_type, variant_name=variant_name)


@router.get(
Expand Down
3 changes: 2 additions & 1 deletion src/hub_api/helpers/etag.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import TYPE_CHECKING, Annotated, override

from fastapi import Header, HTTPException, Request, Response
from pydantic.experimental.missing_sentinel import MISSING
from starlette.middleware.base import BaseHTTPMiddleware

from . import compatibility
Expand Down Expand Up @@ -78,7 +79,7 @@ async def dispatch(

def check_etag(
request: Request,
if_none_match: Annotated[str, Header(description=DESCRIPTION)] = None, # type: ignore[assignment] # ty:ignore[invalid-parameter-default] # ruff: ignore[implicit-optional]
if_none_match: Annotated[str | MISSING, Header(description=DESCRIPTION)] = MISSING,
) -> None:
"""Get ETag value."""
if if_none_match == _get_etag(request):
Expand Down
7 changes: 5 additions & 2 deletions tests/app/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ async def test_plugin_search(api: httpx.AsyncClient) -> None:
"type": "missing",
"loc": ["query", "name"],
"msg": "Field required",
"input": {},
},
"input": {
"type": {"_name": "MISSING", "_repr": "MISSING", "__module__": "pydantic_core"},
"variant": {"_name": "MISSING", "_repr": "MISSING", "__module__": "pydantic_core"},
},
}
]
}

Expand Down
28 changes: 6 additions & 22 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading