zzstoatzz commited on
Commit
76b8ceb
·
1 Parent(s): 86cc07a

fix deprecation warnings

Browse files
README.md CHANGED
@@ -113,7 +113,7 @@ For development, install with:
113
  git clone https://github.com/jlowin/fastmcp.git
114
  cd fastmcp
115
  # Install with dev dependencies
116
- uv sync --dev
117
  ```
118
 
119
  ## Quickstart
@@ -589,7 +589,7 @@ Contributions make the open-source community vibrant! We welcome improvements an
589
  #### Setup
590
 
591
  1. Clone: `git clone https://github.com/jlowin/fastmcp.git && cd fastmcp`
592
- 2. Install Env & Dependencies: `uv venv && uv sync --dev` (Activate the `.venv` after creation)
593
 
594
  #### Testing
595
 
 
113
  git clone https://github.com/jlowin/fastmcp.git
114
  cd fastmcp
115
  # Install with dev dependencies
116
+ uv sync
117
  ```
118
 
119
  ## Quickstart
 
589
  #### Setup
590
 
591
  1. Clone: `git clone https://github.com/jlowin/fastmcp.git && cd fastmcp`
592
+ 2. Install Env & Dependencies: `uv venv && uv sync` (Activate the `.venv` after creation)
593
 
594
  #### Testing
595
 
pyproject.toml CHANGED
@@ -16,12 +16,6 @@ requires-python = ">=3.10"
16
  readme = "README.md"
17
  license = { text = "Apache-2.0" }
18
 
19
- [project.scripts]
20
- fastmcp = "fastmcp.cli:app"
21
-
22
- [project.optional-dependencies]
23
-
24
-
25
  [dependency-groups]
26
  dev = [
27
  "pre-commit",
@@ -36,23 +30,32 @@ dev = [
36
  "pdbpp>=0.10.3",
37
  "dirty-equals>=0.9.0",
38
  ]
 
 
 
 
39
  [build-system]
40
- requires = ["hatchling>=1.21.0", "hatch-vcs>=0.4.0"]
41
  build-backend = "hatchling.build"
42
 
 
 
 
 
 
 
 
 
 
43
  [tool.uv]
44
- # no default groups
45
- default-groups = []
46
 
47
  [tool.pytest.ini_options]
48
  asyncio_mode = "auto"
49
  asyncio_default_fixture_loop_scope = "session"
50
- filterwarnings = [
51
- "ignore:Accessing the 'model_fields' attribute on the instance is deprecated:DeprecationWarning",
52
- ]
53
 
54
- [tool.hatch.version]
55
- source = "vcs"
56
 
57
  [tool.pyright]
58
  include = ["src", "tests"]
@@ -67,7 +70,7 @@ venvPath = "."
67
  venv = ".venv"
68
 
69
  [tool.ruff.lint]
70
- extend-select = ["I"]
71
 
72
  [tool.ruff.lint.per-file-ignores]
73
  "__init__.py" = ["F401", "I001", "RUF013"]
 
16
  readme = "README.md"
17
  license = { text = "Apache-2.0" }
18
 
 
 
 
 
 
 
19
  [dependency-groups]
20
  dev = [
21
  "pre-commit",
 
30
  "pdbpp>=0.10.3",
31
  "dirty-equals>=0.9.0",
32
  ]
33
+
34
+ [project.scripts]
35
+ fastmcp = "fastmcp.cli:app"
36
+
37
  [build-system]
38
+ requires = ["hatchling", "uv-dynamic-versioning>=0.7.0"]
39
  build-backend = "hatchling.build"
40
 
41
+ [tool.hatch.version]
42
+ source = "uv-dynamic-versioning"
43
+
44
+ [tool.uv-dynamic-versioning]
45
+ vcs = "git"
46
+ style = "pep440"
47
+ bump = true
48
+ fallback-version = "0.0.0"
49
+
50
  [tool.uv]
51
+ # uncomment to omit `dev` default group
52
+ # default-groups = []
53
 
54
  [tool.pytest.ini_options]
55
  asyncio_mode = "auto"
56
  asyncio_default_fixture_loop_scope = "session"
57
+ filterwarnings = []
 
 
58
 
 
 
59
 
60
  [tool.pyright]
61
  include = ["src", "tests"]
 
70
  venv = ".venv"
71
 
72
  [tool.ruff.lint]
73
+ extend-select = ["I", "UP"]
74
 
75
  [tool.ruff.lint.per-file-ignores]
76
  "__init__.py" = ["F401", "I001", "RUF013"]
src/fastmcp/utilities/func_metadata.py CHANGED
@@ -27,7 +27,7 @@ class ArgModelBase(BaseModel):
27
  That is, sub-models etc are not dumped - they are kept as pydantic models.
28
  """
29
  kwargs: dict[str, Any] = {}
30
- for field_name in self.model_fields.keys():
31
  kwargs[field_name] = getattr(self, field_name)
32
  return kwargs
33
 
 
27
  That is, sub-models etc are not dumped - they are kept as pydantic models.
28
  """
29
  kwargs: dict[str, Any] = {}
30
+ for field_name in self.__class__.model_fields.keys():
31
  kwargs[field_name] = getattr(self, field_name)
32
  return kwargs
33
 
src/fastmcp/utilities/openapi.py CHANGED
@@ -1,6 +1,6 @@
1
  import json
2
  import logging
3
- from typing import Any, Literal, Union, cast
4
 
5
  # Using the recommended library: openapi-pydantic
6
  from openapi_pydantic import (
@@ -92,7 +92,7 @@ __all__ = [
92
 
93
 
94
  def _resolve_ref(
95
- item: Union[Reference, Schema, Parameter, RequestBody, Any], openapi: OpenAPI
96
  ) -> Any:
97
  """Resolves a potential Reference object to its target definition (no changes needed here)."""
98
  if isinstance(item, Reference):
@@ -110,7 +110,7 @@ def _resolve_ref(
110
  elif isinstance(target, BaseModel):
111
  # Use model_extra for fields not explicitly defined (like components types)
112
  # Check class fields first, then model_extra
113
- if part in target.model_fields: # Access class attribute here
114
  target = getattr(target, part, None)
115
  elif target.model_extra and part in target.model_extra:
116
  target = target.model_extra[part]
@@ -141,7 +141,7 @@ def _resolve_ref(
141
 
142
 
143
  def _extract_schema_as_dict(
144
- schema_obj: Union[Schema, Reference], openapi: OpenAPI
145
  ) -> JsonSchema:
146
  """Resolves a schema/reference and returns it as a dictionary."""
147
  resolved_schema = _resolve_ref(schema_obj, openapi)
@@ -177,8 +177,8 @@ def _convert_to_parameter_location(param_in: str) -> ParameterLocation:
177
 
178
 
179
  def _extract_parameters(
180
- operation_params: list[Union[Parameter, Reference]] | None,
181
- path_item_params: list[Union[Parameter, Reference]] | None,
182
  openapi: OpenAPI,
183
  ) -> list[ParameterInfo]:
184
  """Extracts and resolves parameters using corrected attribute names."""
 
1
  import json
2
  import logging
3
+ from typing import Any, Literal, cast
4
 
5
  # Using the recommended library: openapi-pydantic
6
  from openapi_pydantic import (
 
92
 
93
 
94
  def _resolve_ref(
95
+ item: Reference | Schema | Parameter | RequestBody | Any, openapi: OpenAPI
96
  ) -> Any:
97
  """Resolves a potential Reference object to its target definition (no changes needed here)."""
98
  if isinstance(item, Reference):
 
110
  elif isinstance(target, BaseModel):
111
  # Use model_extra for fields not explicitly defined (like components types)
112
  # Check class fields first, then model_extra
113
+ if part in target.__class__.model_fields:
114
  target = getattr(target, part, None)
115
  elif target.model_extra and part in target.model_extra:
116
  target = target.model_extra[part]
 
141
 
142
 
143
  def _extract_schema_as_dict(
144
+ schema_obj: Schema | Reference, openapi: OpenAPI
145
  ) -> JsonSchema:
146
  """Resolves a schema/reference and returns it as a dictionary."""
147
  resolved_schema = _resolve_ref(schema_obj, openapi)
 
177
 
178
 
179
  def _extract_parameters(
180
+ operation_params: list[Parameter | Reference] | None,
181
+ path_item_params: list[Parameter | Reference] | None,
182
  openapi: OpenAPI,
183
  ) -> list[ParameterInfo]:
184
  """Extracts and resolves parameters using corrected attribute names."""
uv.lock CHANGED
@@ -1,4 +1,5 @@
1
  version = 1
 
2
  requires-python = ">=3.10"
3
 
4
  [[package]]
@@ -127,7 +128,7 @@ name = "click"
127
  version = "8.1.8"
128
  source = { registry = "https://pypi.org/simple" }
129
  dependencies = [
130
- { name = "colorama", marker = "platform_system == 'Windows'" },
131
  ]
132
  sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593 }
133
  wheels = [
@@ -230,7 +231,7 @@ name = "fancycompleter"
230
  version = "0.9.1"
231
  source = { registry = "https://pypi.org/simple" }
232
  dependencies = [
233
- { name = "pyreadline", marker = "platform_system == 'Windows'" },
234
  { name = "pyrepl" },
235
  ]
236
  sdist = { url = "https://files.pythonhosted.org/packages/a9/95/649d135442d8ecf8af5c7e235550c628056423c96c4bc6787348bdae9248/fancycompleter-0.9.1.tar.gz", hash = "sha256:09e0feb8ae242abdfd7ef2ba55069a46f011814a80fe5476be48f51b00247272", size = 10866 }
@@ -254,7 +255,6 @@ wheels = [
254
 
255
  [[package]]
256
  name = "fastmcp"
257
- version = "0.4.2.dev40+g8720a78.d20250410"
258
  source = { editable = "." }
259
  dependencies = [
260
  { name = "dotenv" },
 
1
  version = 1
2
+ revision = 1
3
  requires-python = ">=3.10"
4
 
5
  [[package]]
 
128
  version = "8.1.8"
129
  source = { registry = "https://pypi.org/simple" }
130
  dependencies = [
131
+ { name = "colorama", marker = "sys_platform == 'win32'" },
132
  ]
133
  sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593 }
134
  wheels = [
 
231
  version = "0.9.1"
232
  source = { registry = "https://pypi.org/simple" }
233
  dependencies = [
234
+ { name = "pyreadline", marker = "sys_platform == 'win32'" },
235
  { name = "pyrepl" },
236
  ]
237
  sdist = { url = "https://files.pythonhosted.org/packages/a9/95/649d135442d8ecf8af5c7e235550c628056423c96c4bc6787348bdae9248/fancycompleter-0.9.1.tar.gz", hash = "sha256:09e0feb8ae242abdfd7ef2ba55069a46f011814a80fe5476be48f51b00247272", size = 10866 }
 
255
 
256
  [[package]]
257
  name = "fastmcp"
 
258
  source = { editable = "." }
259
  dependencies = [
260
  { name = "dotenv" },