pydantic: Incompatibility with Cython-3
Initial Checks
- I have searched GitHub for a duplicate issue and I’m sure this is something new
- I have searched Google & StackOverflow for a solution and couldn’t find anything
- I have read and followed the docs and still think this is a bug
- I am confident that the issue is with pydantic (not my code, or another library in the ecosystem like FastAPI or mypy)
Description
We’re testing Python packages against Cython==3.0.0b2
right now, and I’m getting severe-looking errors when trying to run pydantic’s test suite when the extension is compiled with Cython 3:
pytest output
========================================================= test session starts =========================================================
platform linux -- Python 3.10.11, pytest-7.3.1, pluggy-1.0.0 -- /tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8-python3_10/install/usr/bin/python3.10
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/.hypothesis/examples')
rootdir: /tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8
configfile: setup.cfg
testpaths: tests
collecting ... collected 1250 items / 13 errors / 35 deselected / 1215 selected
=============================================================== ERRORS ================================================================
______________________________________________ ERROR collecting tests/test_annotated.py _______________________________________________
tests/test_annotated.py:22: in <module>
Field(default=5, ge=0),
E TypeError: Argument 'ge' has incorrect type (expected float, got int)
Annotated = <class 'typing.Annotated'>
BaseModel = <class 'pydantic.main.BaseModel'>
Field = <cyfunction Field at 0x7eff7bc46a80>
List = typing.List
Undefined = PydanticUndefined
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_annotated.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_annotated.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_annotated'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_annotated', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_annotated.py')
get_all_type_hints = <cyfunction get_all_type_hints at 0x7eff7bf665a0>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
_____________________________________________ ERROR collecting tests/test_construction.py _____________________________________________
tests/test_construction.py:10: in <module>
class Model(BaseModel):
Any = typing.Any
BaseModel = <class 'pydantic.main.BaseModel'>
Field = <cyfunction Field at 0x7eff7bc46a80>
List = typing.List
Optional = typing.Optional
PrivateAttr = <cyfunction PrivateAttr at 0x7eff7bc001e0>
Undefined = PydanticUndefined
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_construction.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_construction.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_construction'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_construction', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_construction.py')
pickle = <module 'pickle' from '/usr/lib/python3.10/pickle.py'>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
_____________________________________________ ERROR collecting tests/test_dataclasses.py ______________________________________________
tests/test_dataclasses.py:973: in gen_2162_dataclasses
class PydanticFoo:
StdLibFoo = <class 'tests.test_dataclasses.gen_2162_dataclasses.<locals>.StdLibFoo'>
pydantic/dataclasses.py:224: in pydantic.dataclasses.dataclass.wrap
???
pydantic/dataclasses.py:347: in pydantic.dataclasses._add_pydantic_validation_attributes
???
pydantic/dataclasses.py:400: in pydantic.dataclasses.create_pydantic_model_from_dataclass
???
pydantic/main.py:1026: in pydantic.main.create_model
???
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
__________________________________________ ERROR collecting tests/test_hypothesis_plugin.py ___________________________________________
tests/test_hypothesis_plugin.py:21: in gen_models
class MiscModel(pydantic.BaseModel):
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
_________________________________________________ ERROR collecting tests/test_json.py _________________________________________________
tests/test_json.py:55: in <module>
(create_model('BarModel', a='b', c='d')(), '{"a": "b", "c": "d"}'),
BaseModel = <class 'pydantic.main.BaseModel'>
Color = <class 'pydantic.color.Color'>
ConstrainedDecimal = <class 'pydantic.types.ConstrainedDecimal'>
Decimal = <class 'decimal.Decimal'>
DirectoryPath = <class 'pydantic.types.DirectoryPath'>
Enum = <enum 'Enum'>
FilePath = <class 'pydantic.types.FilePath'>
IPv4Address = <class 'ipaddress.IPv4Address'>
IPv4Interface = <class 'ipaddress.IPv4Interface'>
IPv4Network = <class 'ipaddress.IPv4Network'>
IPv6Address = <class 'ipaddress.IPv6Address'>
IPv6Interface = <class 'ipaddress.IPv6Interface'>
IPv6Network = <class 'ipaddress.IPv6Network'>
List = typing.List
MyEnum = <enum 'MyEnum'>
NameEmail = <class 'pydantic.networks.NameEmail'>
Optional = typing.Optional
Path = <class 'pathlib.Path'>
SecretBytes = <class 'pydantic.types.SecretBytes'>
SecretStr = <class 'pydantic.types.SecretStr'>
UUID = <class 'uuid.UUID'>
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_json.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_json.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_json'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_json', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_json.py')
create_model = <cyfunction create_model at 0x7eff7bc03ac0>
datetime = <module 'datetime' from '/usr/lib/python3.10/datetime.py'>
json = <module 'json' from '/usr/lib/python3.10/json/__init__.py'>
pydantic_dataclass = <cyfunction dataclass at 0x7eff7bc03c60>
pydantic_encoder = <cyfunction pydantic_encoder at 0x7eff7bc45490>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
re = <module 're' from '/usr/lib/python3.10/re.py'>
sys = <module 'sys' (built-in)>
timedelta_isoformat = <cyfunction timedelta_isoformat at 0x7eff7bc45630>
vanilla_dataclass = <function dataclass at 0x7eff7d271ea0>
pydantic/main.py:1026: in pydantic.main.create_model
???
pydantic/main.py:220: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
_________________________________________________ ERROR collecting tests/test_main.py _________________________________________________
tests/test_main.py:54: in <module>
class UltraSimpleModel(BaseModel):
Annotated = <class 'typing.Annotated'>
Any = typing.Any
BaseConfig = <class 'pydantic.config.BaseConfig'>
BaseModel = <class 'pydantic.main.BaseModel'>
Callable = typing.Callable
ClassVar = typing.ClassVar
ConfigError = <class 'pydantic.errors.ConfigError'>
Counter = typing.Counter
DefaultDict = typing.DefaultDict
Dict = typing.Dict
Enum = <enum 'Enum'>
Extra = <enum 'Extra'>
Field = <cyfunction Field at 0x7eff7bc46a80>
Final = typing.Final
List = typing.List
Literal = typing.Literal
Mapping = typing.Mapping
NoneBytes = typing.Optional[bytes]
NoneStr = typing.Optional[str]
Optional = typing.Optional
PrivateAttr = <cyfunction PrivateAttr at 0x7eff7bc001e0>
Required = Ellipsis
SecretStr = <class 'pydantic.types.SecretStr'>
Type = typing.Type
TypeVar = <class 'typing.TypeVar'>
UUID = <class 'uuid.UUID'>
ValidationError = <class 'pydantic.error_wrappers.ValidationError'>
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_main.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_main.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_main'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_main', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_main.py')
constr = <cyfunction constr at 0x7eff7bdc17d0>
deepcopy = <function deepcopy at 0x7eff7d215750>
defaultdict = <class 'collections.defaultdict'>
get_type_hints = <function get_type_hints at 0x7eff7d2f7880>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
root_validator = <cyfunction root_validator at 0x7eff7bd84860>
sys = <module 'sys' (built-in)>
test_success = <function test_success at 0x7ef77811b640>
uuid4 = <function uuid4 at 0x7eff7cddf0a0>
validator = <cyfunction validator at 0x7eff7bd84790>
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
________________________________________________ ERROR collecting tests/test_parse.py _________________________________________________
tests/test_parse.py:10: in <module>
class Model(BaseModel):
BaseModel = <class 'pydantic.main.BaseModel'>
Field = <cyfunction Field at 0x7eff7bc46a80>
List = typing.List
Protocol = <enum 'Protocol'>
Tuple = typing.Tuple
Union = typing.Union
ValidationError = <class 'pydantic.error_wrappers.ValidationError'>
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_parse.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_parse.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_parse'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_parse', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_parse.py')
json = <module 'json' from '/usr/lib/python3.10/json/__init__.py'>
parse_obj_as = <cyfunction parse_obj_as at 0x7eff7bc5e4d0>
pickle = <module 'pickle' from '/usr/lib/python3.10/pickle.py'>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
______________________________________________ ERROR collecting tests/test_rich_repr.py _______________________________________________
tests/test_rich_repr.py:8: in <module>
class User(BaseModel):
BaseModel = <class 'pydantic.main.BaseModel'>
Color = <class 'pydantic.color.Color'>
List = typing.List
Optional = typing.Optional
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_rich_repr.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_rich_repr.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_rich_repr'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_rich_repr', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_rich_repr.py')
datetime = <class 'datetime.datetime'>
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
________________________________________________ ERROR collecting tests/test_schema.py ________________________________________________
tests/test_schema.py:685: in <module>
class Foo(BaseModel):
Annotated = <class 'typing.Annotated'>
Any = typing.Any
AnyUrl = <class 'pydantic.networks.AnyUrl'>
BaseModel = <class 'pydantic.main.BaseModel'>
Callable = typing.Callable
Color = <class 'pydantic.color.Color'>
ConstrainedBytes = <class 'pydantic.types.ConstrainedBytes'>
ConstrainedDate = <class 'pydantic.types.ConstrainedDate'>
ConstrainedDecimal = <class 'pydantic.types.ConstrainedDecimal'>
ConstrainedFloat = <class 'pydantic.types.ConstrainedFloat'>
ConstrainedInt = <class 'pydantic.types.ConstrainedInt'>
ConstrainedStr = <class 'pydantic.types.ConstrainedStr'>
Decimal = <class 'decimal.Decimal'>
Deque = typing.Deque
Dict = typing.Dict
DirectoryPath = <class 'pydantic.types.DirectoryPath'>
EmailStr = <class 'pydantic.networks.EmailStr'>
Enum = <enum 'Enum'>
Extra = <enum 'Extra'>
Field = <cyfunction Field at 0x7eff7bc46a80>
FilePath = <class 'pydantic.types.FilePath'>
FrozenSet = typing.FrozenSet
Generic = <class 'typing.Generic'>
GenericModel = <class 'pydantic.generics.GenericModel'>
IPv4Address = <class 'ipaddress.IPv4Address'>
IPv4Interface = <class 'ipaddress.IPv4Interface'>
IPv4Network = <class 'ipaddress.IPv4Network'>
IPv6Address = <class 'ipaddress.IPv6Address'>
IPv6Interface = <class 'ipaddress.IPv6Interface'>
IPv6Network = <class 'ipaddress.IPv6Network'>
IPvAnyAddress = <class 'pydantic.networks.IPvAnyAddress'>
IPvAnyInterface = <class 'pydantic.networks.IPvAnyInterface'>
IPvAnyNetwork = <class 'pydantic.networks.IPvAnyNetwork'>
IntEnum = <enum 'IntEnum'>
Iterable = typing.Iterable
Json = <class 'pydantic.types.Json'>
List = typing.List
Literal = typing.Literal
ModelField = <class 'pydantic.fields.ModelField'>
NameEmail = <class 'pydantic.networks.NameEmail'>
NamedTuple = <function NamedTuple at 0x7eff7d100700>
NegativeFloat = <class 'pydantic.types.NegativeFloat'>
NegativeInt = <class 'pydantic.types.NegativeInt'>
NewType = <class 'typing.NewType'>
NonNegativeFloat = <class 'pydantic.types.NonNegativeFloat'>
NonNegativeInt = <class 'pydantic.types.NonNegativeInt'>
NonPositiveFloat = <class 'pydantic.types.NonPositiveFloat'>
NonPositiveInt = <class 'pydantic.types.NonPositiveInt'>
NoneBytes = typing.Optional[bytes]
NoneStr = typing.Optional[str]
NoneStrBytes = typing.Union[str, bytes, NoneType]
Optional = typing.Optional
Path = <class 'pathlib.Path'>
Pattern = typing.Pattern
PositiveFloat = <class 'pydantic.types.PositiveFloat'>
PositiveInt = <class 'pydantic.types.PositiveInt'>
PyObject = <class 'pydantic.types.PyObject'>
SecretBytes = <class 'pydantic.types.SecretBytes'>
SecretStr = <class 'pydantic.types.SecretStr'>
Set = typing.Set
StrBytes = typing.Union[str, bytes]
StrictBool = <class 'pydantic.types.StrictBool'>
StrictStr = <class 'pydantic.types.StrictStr'>
T = ~T
Tuple = typing.Tuple
Type = typing.Type
TypeVar = <class 'typing.TypeVar'>
UUID = <class 'uuid.UUID'>
UUID1 = <class 'pydantic.types.UUID1'>
UUID3 = <class 'pydantic.types.UUID3'>
UUID4 = <class 'pydantic.types.UUID4'>
UUID5 = <class 'pydantic.types.UUID5'>
Union = typing.Union
ValidationError = <class 'pydantic.error_wrappers.ValidationError'>
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_schema.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_schema.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_schema'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_schema', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_schema.py')
conbytes = <cyfunction conbytes at 0x7eff7bdc13c0>
condate = <cyfunction condate at 0x7eff7bc44ee0>
condecimal = <cyfunction condecimal at 0x7eff7bdc2740>
confloat = <cyfunction confloat at 0x7eff7bdc1150>
confrozenset = <cyfunction confrozenset at 0x7eff7bdc1e50>
conint = <cyfunction conint at 0x7eff7bdc0ee0>
conlist = <cyfunction conlist at 0x7eff7bdc2260>
conset = <cyfunction conset at 0x7eff7bdc1b10>
constr = <cyfunction constr at 0x7eff7bdc17d0>
dataclass = <cyfunction dataclass at 0x7eff7bc03c60>
date = <class 'datetime.date'>
datetime = <class 'datetime.datetime'>
email_validator = <module 'email_validator' from '/usr/lib/python3.10/site-packages/email_validator/__init__.py'>
get_flat_models_from_model = <cyfunction get_flat_models_from_model at 0x7eff7bc01150>
get_flat_models_from_models = <cyfunction get_flat_models_from_models at 0x7eff7bc013c0>
get_model_name_map = <cyfunction get_model_name_map at 0x7eff7bc01080>
json = <module 'json' from '/usr/lib/python3.10/json/__init__.py'>
math = <module 'math' from '/usr/lib/python3.10/lib-dynload/math.cpython-310-x86_64-linux-gnu.so'>
model_process_schema = <cyfunction model_process_schema at 0x7eff7bc01630>
model_schema = <cyfunction model_schema at 0x7eff7bc00d40>
os = <module 'os' from '/usr/lib/python3.10/os.py'>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
re = <module 're' from '/usr/lib/python3.10/re.py'>
schema = <cyfunction schema at 0x7eff7bc00c70>
stricturl = <cyfunction stricturl at 0x7eff7bdcf6b0>
sys = <module 'sys' (built-in)>
tempfile = <module 'tempfile' from '/usr/lib/python3.10/tempfile.py'>
test_any = <function test_any at 0x7ef77824a4d0>
test_bool = <function test_bool at 0x7ef77824a830>
test_by_alias = <function test_by_alias at 0x7ef778249b40>
test_by_alias_generator = <function test_by_alias_generator at 0x7ef778249c60>
test_choices = <function test_choices at 0x7ef778249f30>
test_const_false = <function test_const_false at 0x7ef77824a680>
test_const_str = <function test_const_str at 0x7ef77824a5f0>
test_deque = <function test_deque at 0x7ef77824a7a0>
test_dict = <function test_dict at 0x7ef77824a950>
test_enum_and_model_have_same_behaviour = <function test_enum_and_model_have_same_behaviour at 0x7ef77824a0e0>
test_enum_includes_extra_without_other_params = <function test_enum_includes_extra_without_other_params at 0x7ef77824a170>
test_enum_modify_schema = <function test_enum_modify_schema at 0x7ef778249fc0>
test_enum_schema_cleandoc = <function test_enum_schema_cleandoc at 0x7ef77824a290>
test_enum_schema_custom_field = <function test_enum_schema_custom_field at 0x7ef77824a050>
test_json_schema = <function test_json_schema at 0x7ef77824a320>
test_key = <function test_key at 0x7ef77811aef0>
test_list = <function test_list at 0x7ef77824a9e0>
test_list_enum_schema_extras = <function test_list_enum_schema_extras at 0x7ef77824a200>
test_list_sub_model = <function test_list_sub_model at 0x7ef77824a3b0>
test_optional = <function test_optional at 0x7ef77824a440>
test_ref_template = <function test_ref_template at 0x7ef778249bd0>
test_schema_class = <function test_schema_class at 0x7ef778249d80>
test_schema_class_by_alias = <function test_schema_class_by_alias at 0x7ef778249ea0>
test_schema_repr = <function test_schema_repr at 0x7ef778249e10>
test_set = <function test_set at 0x7ef77824a560>
test_strict_bool = <function test_strict_bool at 0x7ef77824a8c0>
test_sub_model = <function test_sub_model at 0x7ef778249cf0>
test_tuple = <function test_tuple at 0x7ef77824a710>
time = <class 'datetime.time'>
timedelta = <class 'datetime.timedelta'>
validator = <cyfunction validator at 0x7eff7bd84790>
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
_______________________________________________ ERROR collecting tests/test_settings.py _______________________________________________
tests/test_settings.py:26: in <module>
class SimpleSettings(BaseSettings):
Any = typing.Any
BaseModel = <class 'pydantic.main.BaseModel'>
BaseSettings = <class 'pydantic.env_settings.BaseSettings'>
Callable = typing.Callable
Dict = typing.Dict
EnvSettingsSource = <class 'pydantic.env_settings.EnvSettingsSource'>
Field = <cyfunction Field at 0x7eff7bc46a80>
HttpUrl = <class 'pydantic.networks.HttpUrl'>
InitSettingsSource = <class 'pydantic.env_settings.InitSettingsSource'>
List = typing.List
NoneStr = typing.Optional[str]
Optional = typing.Optional
Path = <class 'pathlib.Path'>
SecretStr = <class 'pydantic.types.SecretStr'>
SecretsSettingsSource = <class 'pydantic.env_settings.SecretsSettingsSource'>
Set = typing.Set
SettingsError = <class 'pydantic.env_settings.SettingsError'>
SettingsSourceCallable = typing.Callable[[ForwardRef('BaseSettings')], typing.Dict[str, typing.Any]]
Tuple = typing.Tuple
Union = typing.Union
ValidationError = <class 'pydantic.error_wrappers.ValidationError'>
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_settings.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_settings.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_settings'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_settings', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_settings.py')
dataclasses = <module 'pydantic.dataclasses' from '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8-python3_10/install/usr/lib/python3.10/site-packages/pydantic/dataclasses.cpython-310-x86_64-linux-gnu.so'>
datetime = <class 'datetime.datetime'>
dotenv = <module 'dotenv' from '/usr/lib/python3.10/site-packages/dotenv/__init__.py'>
os = <module 'os' from '/usr/lib/python3.10/os.py'>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
read_env_file = <cyfunction read_env_file at 0x7eff7bc5e0c0>
sys = <module 'sys' (built-in)>
timezone = <class 'datetime.timezone'>
uuid = <module 'uuid' from '/usr/lib/python3.10/uuid.py'>
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
________________________________________________ ERROR collecting tests/test_types.py _________________________________________________
tests/test_types.py:89: in <module>
class ConBytesModel(BaseModel):
Any = typing.Any
BaseModel = <class 'pydantic.main.BaseModel'>
ByteSize = <class 'pydantic.types.ByteSize'>
ConfigError = <class 'pydantic.errors.ConfigError'>
Decimal = <class 'decimal.Decimal'>
Deque = typing.Deque
Dict = typing.Dict
DirectoryPath = <class 'pydantic.types.DirectoryPath'>
EmailStr = <class 'pydantic.networks.EmailStr'>
Enum = <enum 'Enum'>
Field = <cyfunction Field at 0x7eff7bc46a80>
FilePath = <class 'pydantic.types.FilePath'>
FiniteFloat = <class 'pydantic.types.FiniteFloat'>
FrozenSet = typing.FrozenSet
FutureDate = <class 'pydantic.types.FutureDate'>
IntEnum = <enum 'IntEnum'>
Iterable = typing.Iterable
Iterator = typing.Iterator
Json = <class 'pydantic.types.Json'>
List = typing.List
Literal = typing.Literal
MutableSet = typing.MutableSet
NameEmail = <class 'pydantic.networks.NameEmail'>
NegativeFloat = <class 'pydantic.types.NegativeFloat'>
NegativeInt = <class 'pydantic.types.NegativeInt'>
NewType = <class 'typing.NewType'>
NonNegativeFloat = <class 'pydantic.types.NonNegativeFloat'>
NonNegativeInt = <class 'pydantic.types.NonNegativeInt'>
NonPositiveFloat = <class 'pydantic.types.NonPositiveFloat'>
NonPositiveInt = <class 'pydantic.types.NonPositiveInt'>
NoneType = <class 'NoneType'>
Optional = typing.Optional
OrderedDict = <class 'collections.OrderedDict'>
PastDate = <class 'pydantic.types.PastDate'>
Path = <class 'pathlib.Path'>
Pattern = typing.Pattern
PositiveFloat = <class 'pydantic.types.PositiveFloat'>
PositiveInt = <class 'pydantic.types.PositiveInt'>
PyObject = <class 'pydantic.types.PyObject'>
SecretBytes = <class 'pydantic.types.SecretBytes'>
SecretField = <class 'pydantic.types.SecretField'>
SecretStr = <class 'pydantic.types.SecretStr'>
Sequence = typing.Sequence
Set = typing.Set
StrictBool = <class 'pydantic.types.StrictBool'>
StrictBytes = <class 'pydantic.types.StrictBytes'>
StrictFloat = <class 'pydantic.types.StrictFloat'>
StrictInt = <class 'pydantic.types.StrictInt'>
StrictStr = <class 'pydantic.types.StrictStr'>
Tuple = typing.Tuple
TypedDict = <class 'typing_extensions.TypedDict'>
UUID = <class 'uuid.UUID'>
UUID1 = <class 'pydantic.types.UUID1'>
UUID3 = <class 'pydantic.types.UUID3'>
UUID4 = <class 'pydantic.types.UUID4'>
UUID5 = <class 'pydantic.types.UUID5'>
Union = typing.Union
ValidationError = <class 'pydantic.error_wrappers.ValidationError'>
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_types.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_types.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_types'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_types', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_types.py')
conbytes = <cyfunction conbytes at 0x7eff7bdc13c0>
condecimal = <cyfunction condecimal at 0x7eff7bdc2740>
confloat = <cyfunction confloat at 0x7eff7bdc1150>
confrozenset = <cyfunction confrozenset at 0x7eff7bdc1e50>
conint = <cyfunction conint at 0x7eff7bdc0ee0>
conlist = <cyfunction conlist at 0x7eff7bdc2260>
conset = <cyfunction conset at 0x7eff7bdc1b10>
constr = <cyfunction constr at 0x7eff7bdc17d0>
create_model = <cyfunction create_model at 0x7eff7bc03ac0>
date = <class 'datetime.date'>
datetime = <class 'datetime.datetime'>
deque = <class 'collections.deque'>
email_validator = <module 'email_validator' from '/usr/lib/python3.10/site-packages/email_validator/__init__.py'>
errors = <module 'pydantic.errors' from '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8-python3_10/install/usr/lib/python3.10/site-packages/pydantic/errors.cpython-310-x86_64-linux-gnu.so'>
itertools = <module 'itertools' (built-in)>
math = <module 'math' from '/usr/lib/python3.10/lib-dynload/math.cpython-310-x86_64-linux-gnu.so'>
os = <module 'os' from '/usr/lib/python3.10/os.py'>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
re = <module 're' from '/usr/lib/python3.10/re.py'>
sys = <module 'sys' (built-in)>
time = <class 'datetime.time'>
timedelta = <class 'datetime.timedelta'>
uuid = <module 'uuid' from '/usr/lib/python3.10/uuid.py'>
validator = <cyfunction validator at 0x7eff7bd84790>
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
______________________________________ ERROR collecting tests/test_types_payment_card_number.py _______________________________________
tests/test_types_payment_card_number.py:25: in <module>
class PaymentCard(BaseModel):
Any = typing.Any
BaseModel = <class 'pydantic.main.BaseModel'>
InvalidLengthForBrand = <class 'pydantic.errors.InvalidLengthForBrand'>
LEN_INVALID = '40000000000000006'
LUHN_INVALID = '4000000000000000'
LuhnValidationError = <class 'pydantic.errors.LuhnValidationError'>
NotDigitError = <class 'pydantic.errors.NotDigitError'>
PCN = <class 'tests.test_types_payment_card_number.PaymentCardNumber'>
PaymentCardBrand = <enum 'PaymentCardBrand'>
PaymentCardNumber = <class 'pydantic.types.PaymentCardNumber'>
VALID_AMEX = '370000000000002'
VALID_MC = '5100000000000003'
VALID_OTHER = '2000000000000000008'
VALID_VISA_13 = '4050000000001'
VALID_VISA_16 = '4050000000000001'
VALID_VISA_19 = '4050000000000000001'
ValidationError = <class 'pydantic.error_wrappers.ValidationError'>
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_types_payment_card_number.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_types_payment_card_number.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_types_payment_card_number'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_types_payment_card_number', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_types_payment_card_number.py')
namedtuple = <function namedtuple at 0x7eff7d4dd1b0>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
______________________________________________ ERROR collecting tests/test_validators.py ______________________________________________
tests/test_validators.py:153: in <module>
class ValidateAssignmentModel(BaseModel):
Any = typing.Any
BaseModel = <class 'pydantic.main.BaseModel'>
Callable = typing.Callable
ConfigError = <class 'pydantic.errors.ConfigError'>
Dict = typing.Dict
Enum = <enum 'Enum'>
Extra = <enum 'Extra'>
Field = <cyfunction Field at 0x7eff7bc46a80>
List = typing.List
Literal = typing.Literal
Optional = typing.Optional
Tuple = typing.Tuple
Union = typing.Union
ValidationError = <class 'pydantic.error_wrappers.ValidationError'>
__builtins__ = <builtins>
__cached__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/__pycache__/test_validators.cpython-310.pyc'
__doc__ = None
__file__ = '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_validators.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>
__name__ = 'tests.test_validators'
__package__ = 'tests'
__spec__ = ModuleSpec(name='tests.test_validators', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7eff7c8e41c0>, origin='/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8/tests/test_validators.py')
conlist = <cyfunction conlist at 0x7eff7bdc2260>
datetime = <class 'datetime.datetime'>
deque = <class 'collections.deque'>
errors = <module 'pydantic.errors' from '/tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8-python3_10/install/usr/lib/python3.10/site-packages/pydantic/errors.cpython-310-x86_64-linux-gnu.so'>
make_generic_validator = <cyfunction make_generic_validator at 0x7eff7bd84ee0>
partial = <class 'functools.partial'>
partialmethod = <class 'functools.partialmethod'>
product = <class 'itertools.product'>
pytest = <module 'pytest' from '/usr/lib/python3.10/site-packages/pytest/__init__.py'>
root_validator = <cyfunction root_validator at 0x7eff7bd84860>
test_deque_validation = <function test_deque_validation at 0x7ef77860c5e0>
test_frozenset_validation = <function test_frozenset_validation at 0x7ef77860c430>
test_int_overflow_validation = <function test_int_overflow_validation at 0x7ef778248430>
test_int_validation = <function test_int_validation at 0x7ef7782480d0>
test_simple = <function test_simple at 0x7ef778249bd0>
test_validate_kwargs = <function test_validate_kwargs at 0x7ef77860c700>
test_validate_pre_error = <function test_validate_pre_error at 0x7ef77860c790>
test_validate_whole = <function test_validate_whole at 0x7ef77860c670>
validator = <cyfunction validator at 0x7eff7bd84790>
pydantic/main.py:186: in pydantic.main.ModelMetaclass.__new__
???
E TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
======================================================= short test summary info =======================================================
ERROR tests/test_annotated.py - TypeError: Argument 'ge' has incorrect type (expected float, got int)
ERROR tests/test_construction.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_dataclasses.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_hypothesis_plugin.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_json.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_main.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_parse.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_rich_repr.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_schema.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_settings.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_types.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_types_payment_card_number.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
ERROR tests/test_validators.py - TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 13 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================== 35 deselected, 13 errors in 4.22s ==================================================
Example Code
No response
Python, Pydantic & OS Version
pydantic version: 1.10.8
pydantic compiled: True
install path: /tmp/portage/dev-python/pydantic-1.10.8/work/pydantic-1.10.8-python3_10/install/usr/lib/python3.10/site-packages/pydantic
python version: 3.10.11 (main, Apr 6 2023, 04:27:42) [GCC 12.2.1 20230304]
platform: Linux-6.3.3-gentoo-dist-x86_64-AMD_Ryzen_5_3600_6-Core_Processor-with-glibc2.37
optional deps. installed: ['dotenv', 'email-validator', 'typing-extensions']
Affected Components
- Compatibility between releases
- Data validation/parsing
- Data serialization -
.dict()
and.json()
- JSON Schema
- Dataclasses
- Model Config
- Field Types - adding or changing a particular data type
- Function validation decorator
- Generic Models
- Other Model behaviour -
construct()
, pickling, private attributes, ORM mode - Plugins and integration with other tools - mypy, FastAPI, python-devtools, Hypothesis, VS Code, PyCharm, etc.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (15 by maintainers)
There’s no real need to do that, as Cython-3 is still masked, and it’s unlikely that it’ll be unmasked before we remove the previous version 😉.
pydantic is required by a few Gentoo packages, including packages that aren’t pure Python. We need to provide it to satisfy their dependencies.
Distro packaging has a number of advantages in general (not necessarily applicable to pydantic):
Let me point out that PyPI has been subject to multiple malware waves so far, and the signing infrastructure is still work-in-progress. Even if it is done, establishing the trust to all upstream keys will be a significant undertaking.
Gentoo has signed packages working for years now. Sure, it isn’t perfect but I dare say it’s pretty good for an entirely volunteer project, and to the best of my knowledge we’ve so far managed without a single incident (though it’s quite likely that’s only because nobody cared enough).
I think a much better approach for users is for upstreams to sign their packages, and distributions to take care of verifying upstream signatures, and then signing the resulting packages using the distribution’s key infrastructure. It’s easier for users to reliably verify a single trust anchor, than independently verify all upstreams.