Add flag for disabling deprecation warnings

This commit is contained in:
Jeremiah Lowin 2025-06-11 09:59:35 -04:00
commit 3116ef3892
2 changed files with 21 additions and 0 deletions

View file

@ -1,5 +1,6 @@
"""FastMCP - An ergonomic MCP interface."""
import warnings
from importlib.metadata import version
from fastmcp.settings import Settings
@ -22,3 +23,9 @@ __all__ = [
"settings",
"Image",
]
if settings.deprecation_warnings:
warnings.simplefilter("default", DeprecationWarning)
else:
warnings.simplefilter("ignore", DeprecationWarning)

View file

@ -111,6 +111,20 @@ class Settings(BaseSettings):
),
] = True
deprecation_warnings: Annotated[
bool,
Field(
description=inspect.cleandoc(
"""
Whether to show deprecation warnings. You can completely reset
Python's warning behavior by running `warnings.resetwarnings()`.
Note this will NOT apply to deprecation warnings from the
settings class itself.
""",
)
),
] = True
client_raise_first_exceptiongroup_error: Annotated[
bool,
Field(