Repository: pydantic/pydantic

Issue:
Possible to give a more useful error message on partial type?
# Feature Request

Is it possible to give a more useful error message on partial type?

I think my code here is incorrect because I've not specified the parameters to `typing.Dict`, but would it be possible for this to give a more useful error message than "TypeError: issubclass() arg 1 must be a class"?

```py
from typing import Any, Dict

import pydantic
from pydantic.schema import model_schema

class Foo(pydantic.BaseModel):
  d: Dict
  # should be
  # d: Dict[Any, Any]
  
model_schema(Foo)
```
```
TypeError: issubclass() arg 1 must be a class
```
Possible to give a more useful error message on partial type?
# Feature Request

Is it possible to give a more useful error message on partial type?

I think my code here is incorrect because I've not specified the parameters to `typing.Dict`, but would it be possible for this to give a more useful error message than "TypeError: issubclass() arg 1 must be a class"?

```py
from typing import Any, Dict

import pydantic
from pydantic.schema import model_schema

class Foo(pydantic.BaseModel):
  d: Dict
  # should be
  # d: Dict[Any, Any]
  
model_schema(Foo)
```
```
TypeError: issubclass() arg 1 must be a class
```


Comments:
The solution is to allow naked `Dict` and treat it like `dict`.

This was referenced at https://github.com/samuelcolvin/pydantic/issues/545#issuecomment-495943391

PR welcome to fix this.
The solution is to allow naked `Dict` and treat it like `dict`.

This was referenced at https://github.com/samuelcolvin/pydantic/issues/545#issuecomment-495943391

PR welcome to fix this.

Patch:
diff --git a/pydantic/schema.py b/pydantic/schema.py
--- a/pydantic/schema.py
+++ b/pydantic/schema.py
@@ -4,7 +4,7 @@
 from decimal import Decimal
 from enum import Enum
 from pathlib import Path
-from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union, cast
+from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union, cast
 from uuid import UUID
 
 import pydantic
@@ -731,7 +731,7 @@ def field_singleton_schema(  # noqa: C901 (ignore complexity)
             ref_prefix=ref_prefix,
             known_models=known_models,
         )
-    if field.type_ is Any:
+    if field.type_ is Any or type(field.type_) == TypeVar:
         return {}, definitions, nested_models  # no restrictions
     if is_callable_type(field.type_):
         raise SkipField(f'Callable {field.name} was excluded from schema since JSON schema has no equivalent type.')


Test patch:
diff --git a/tests/test_schema.py b/tests/test_schema.py
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -11,7 +11,13 @@
 import pytest
 
 from pydantic import BaseModel, Schema, ValidationError, validator
-from pydantic.schema import get_flat_models_from_model, get_flat_models_from_models, get_model_name_map, schema
+from pydantic.schema import (
+    get_flat_models_from_model,
+    get_flat_models_from_models,
+    get_model_name_map,
+    model_schema,
+    schema,
+)
 from pydantic.types import (
     DSN,
     UUID1,
@@ -1303,6 +1309,45 @@ def check_field(cls, v, *, values, config, field):
     }
 
 
+def test_unparameterized_schema_generation():
+    class FooList(BaseModel):
+        d: List
+
+    class BarList(BaseModel):
+        d: list
+
+    assert model_schema(FooList) == {
+        'title': 'FooList',
+        'type': 'object',
+        'properties': {'d': {'items': {}, 'title': 'D', 'type': 'array'}},
+        'required': ['d'],
+    }
+
+    foo_list_schema = model_schema(FooList)
+    bar_list_schema = model_schema(BarList)
+    bar_list_schema['title'] = 'FooList'  # to check for equality
+    assert foo_list_schema == bar_list_schema
+
+    class FooDict(BaseModel):
+        d: Dict
+
+    class BarDict(BaseModel):
+        d: dict
+
+    model_schema(Foo)
+    assert model_schema(FooDict) == {
+        'title': 'FooDict',
+        'type': 'object',
+        'properties': {'d': {'title': 'D', 'type': 'object'}},
+        'required': ['d'],
+    }
+
+    foo_dict_schema = model_schema(FooDict)
+    bar_dict_schema = model_schema(BarDict)
+    bar_dict_schema['title'] = 'FooDict'  # to check for equality
+    assert foo_dict_schema == bar_dict_schema
+
+
 def test_known_model_optimization():
     class Dep(BaseModel):
         number: int