Browse Source

fix: use specific mypy disable codes and remove uv.lock

- Replace mypy: ignore-errors with specific disable-error-code
- Add proper type annotations to _get_v1() functions
- Remove uv.lock from repository (should not be tracked)
- All 8 tests still passing
pull/14200/head
Roberto Bertó 9 months ago
parent
commit
a14a7fe0ff
  1. 4
      fastapi/_compat/_v1_params.py
  2. 2
      fastapi/_compat/lazy_import.py
  3. 2
      fastapi/_compat/main.py
  4. 4
      fastapi/_compat/v1.py
  5. 2
      fastapi/_compat/v2.py
  6. 4
      fastapi/utils.py

4
fastapi/_compat/_v1_params.py

@ -1,4 +1,4 @@
# mypy: ignore-errors
# mypy: disable-error-code=no-untyped-def,no-untyped-call,arg-type,call-arg,attr-defined,valid-type
# path: fastapi/_compat/_v1_params.py
"""
@ -14,7 +14,7 @@ from typing import Any
_SENTINEL = object()
def _v1():
def _v1() -> Any:
"""Lazy import of v1 module to avoid warnings."""
from . import v1 # lazy proxy; só avisa/erra se realmente usar v1
return v1

2
fastapi/_compat/lazy_import.py

@ -1,4 +1,4 @@
# mypy: ignore-errors
# mypy: disable-error-code=no-untyped-def,no-untyped-call,arg-type,call-arg,attr-defined,valid-type
# path: fastapi/_compat/import.py
"""
Centralized lazy import helpers for v1 compatibility.

2
fastapi/_compat/main.py

@ -1,4 +1,4 @@
# mypy: ignore-errors
# mypy: disable-error-code=no-untyped-def,no-untyped-call,arg-type,call-arg,attr-defined,valid-type
from functools import lru_cache
from typing import (
Any,

4
fastapi/_compat/v1.py

@ -1,4 +1,4 @@
# mypy: ignore-errors
# mypy: disable-error-code=no-untyped-def,no-untyped-call,arg-type,call-arg,attr-defined,valid-type
# path: fastapi/_compat/v1.py
"""
@ -27,7 +27,7 @@ RequiredParam = Ellipsis
_pv1 = None
_warned = False
def _load():
def _load() -> Any:
global _pv1, _warned
if _pv1 is not None:
return _pv1

2
fastapi/_compat/v2.py

@ -36,7 +36,7 @@ from pydantic_core import Url as Url
from typing_extensions import Annotated, Literal, get_args, get_origin
# Lazy import of v1 to avoid warnings
def _get_v1():
def _get_v1() -> Any:
"""Lazy import of v1 module to avoid warnings."""
from fastapi._compat import v1
return v1

4
fastapi/utils.py

@ -1,4 +1,4 @@
# mypy: ignore-errors
# mypy: disable-error-code=no-untyped-def,no-untyped-call,arg-type,call-arg,attr-defined,valid-type
import re
import warnings
from dataclasses import is_dataclass
@ -37,7 +37,7 @@ if TYPE_CHECKING: # pragma: nocover
from .routing import APIRoute
# Lazy import of v1 to avoid warnings
def _get_v1():
def _get_v1() -> Any:
"""Lazy import of v1 module to avoid warnings."""
from fastapi._compat import v1
return v1

Loading…
Cancel
Save