Repository: pydantic/pydantic

Issue:
Type of validation context
### Initial Checks

- [X] I confirm that I'm using Pydantic V2

### Description

When using BaseModel.model_validate_json() or BaseModel.model_validate() the optional parameter "context" is typed to be a dict[str, Any].
This context is made available to validators via the ValidationInfo object.
The type of the info.context object is "Any | None" instead of "dict[str,Any] | None".

### Example Code

```Python
from typing import Any

from pydantic import BaseModel, model_validator
from pydantic_core.core_schema import ValidationInfo


class Model(BaseModel):
    @model_validator(mode="after")
    def validator(self, info: ValidationInfo) -> Any:
        info.context  # this returns a object of type "Any | None"


Model.model_validate_json("{}", context={})  # type of context has to be "dict[str, Any] | None"
```


### Python, Pydantic & OS Version

```Text
pydantic version: 2.7.1
        pydantic-core version: 2.18.2
          pydantic-core build: profile=release pgo=true
               python version: 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)]
                     platform: Windows-10-10.0.19045-SP0
             related packages: mypy-1.10.0 typing_extensions-4.11.0
```



Discussion:
@OhioDschungel6,

Indeed, looks like our type hints could be improved. Would you be interested in opening a PR to fix this issue? Thanks for bringing it to our attention!
Can we keep `ValidationInfo`'s type annotations for `context` instead of `Model.model_validate[_json]` please? I.e. change the latter to `Any | None` rather than the former to a dict?

The change to `Model.model_validate[_json]` must have been pretty recent - I have code written as far back as Sep 2023 that passes in objects (not dicts) to validation code and a system of strongly typed context objects. It would be a massive pita to convert them to dicts and I'd lose some nice static type safety.

Resolving patch:
diff --git a/pydantic/main.py b/pydantic/main.py
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -327,7 +327,7 @@ def model_dump(
         mode: Literal['json', 'python'] | str = 'python',
         include: IncEx = None,
         exclude: IncEx = None,
-        context: dict[str, Any] | None = None,
+        context: Any | None = None,
         by_alias: bool = False,
         exclude_unset: bool = False,
         exclude_defaults: bool = False,
@@ -380,7 +380,7 @@ def model_dump_json(
         indent: int | None = None,
         include: IncEx = None,
         exclude: IncEx = None,
-        context: dict[str, Any] | None = None,
+        context: Any | None = None,
         by_alias: bool = False,
         exclude_unset: bool = False,
         exclude_defaults: bool = False,
@@ -545,7 +545,7 @@ def model_validate(
         *,
         strict: bool | None = None,
         from_attributes: bool | None = None,
-        context: dict[str, Any] | None = None,
+        context: Any | None = None,
     ) -> Self:
         """Validate a pydantic model instance.
 
@@ -573,7 +573,7 @@ def model_validate_json(
         json_data: str | bytes | bytearray,
         *,
         strict: bool | None = None,
-        context: dict[str, Any] | None = None,
+        context: Any | None = None,
     ) -> Self:
         """Usage docs: https://docs.pydantic.dev/2.7/concepts/json/#json-parsing
 
@@ -600,7 +600,7 @@ def model_validate_strings(
         obj: Any,
         *,
         strict: bool | None = None,
-        context: dict[str, Any] | None = None,
+        context: Any | None = None,
     ) -> Self:
         """Validate the given object contains string data against the Pydantic model.
 


Test patch: