Avatar for the koxudaxi user
koxudaxi
datamodel-code-generator
BlogDocsChangelog

Branches performance

Pull requests

fix: TypeError: '<' not supported between instances of 'str' and 'NoneType'#2380
last run
1 day ago
fix: TypeError: '<' not supported between instances of 'str' and 'NoneType' I'm afraid I don't know exactly what triggers this, but in my big openapi spec this gets triggered: ``` Traceback (most recent call last): File "/home/gjc/.cache/uv/archive-v0/zrUKlPLuGJsfxDV0Mede0/lib/python3.12/site-packages/datamodel_code_generator/__main__.py", line 458, in main generate( File "/home/gjc/.cache/uv/archive-v0/zrUKlPLuGJsfxDV0Mede0/lib/python3.12/site-packages/datamodel_code_generator/__init__.py", line 492, in generate results = parser.parse() ^^^^^^^^^^^^^^ File "/home/gjc/.cache/uv/archive-v0/zrUKlPLuGJsfxDV0Mede0/lib/python3.12/site-packages/datamodel_code_generator/parser/base.py", line 1311, in parse self.__reuse_model(models, require_update_action_models) File "/home/gjc/.cache/uv/archive-v0/zrUKlPLuGJsfxDV0Mede0/lib/python3.12/site-packages/datamodel_code_generator/parser/base.py", line 868, in __reuse_model model_key = tuple(to_hashable(v) for v in (model.render(class_name="M"), model.imports)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gjc/.cache/uv/archive-v0/zrUKlPLuGJsfxDV0Mede0/lib/python3.12/site-packages/datamodel_code_generator/parser/base.py", line 868, in <genexpr> model_key = tuple(to_hashable(v) for v in (model.render(class_name="M"), model.imports)) ^^^^^^^^^^^^^^ File "/home/gjc/.cache/uv/archive-v0/zrUKlPLuGJsfxDV0Mede0/lib/python3.12/site-packages/datamodel_code_generator/parser/base.py", line 76, in to_hashable return tuple(sorted(to_hashable(i) for i in item)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: '<' not supported between instances of 'str' and 'NoneType' ``` The objects in question look like: ``` Import(from_="typing", import_="Annotated", alias=None, reference_path=None) ``` Which are transformed into: ``` ( ("alias", None), ("from_", "typing"), ("import_", "Annotated"), ("reference_path", None), ), ``` Now, those `None`s will cause `sorted()` to raise that TypeError. The simple fix is to transform None into "": this is only used as key in a cache, so it doesn't really matter as long as the value is predictable and hashable.
1 day ago
a0cded2
gjcarneiro:bugfix/hash-None-error
CodSpeed Performance Gauge
0%
Fix shadowed import errors by aliasing conflicting symbols in generated models#2379
last run
3 days ago
[pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci
3 days ago
c3e2948
sternakt:fix-import-shadowing
CodSpeed Performance Gauge
0%
fix(parser): ignore discriminator in collapsed list fields Pydantic will raise an error if a discriminator is provided to a list field.
3 days ago
1b2c24d
rcarriga:fix/list-discriminator
CodSpeed Performance Gauge
-1%
codespell
5 days ago
b313fe1
gjcarneiro:feature/pydantic2-avoid-class-simple-alias
CodSpeed Performance Gauge
0%
© 2025 CodSpeed Technology
Home Terms PrivacyDocs