Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoSign in
Socket

erdantic

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

erdantic - pypi Package Compare versions

Comparing version
1.0.1
to
1.0.2
+8
-1
erdantic/core.py

@@ -516,3 +516,10 @@ from enum import Enum

"""Private recursive method to add a model to the diagram."""
key = str(FullyQualifiedName.from_object(model))
try:
key = str(FullyQualifiedName.from_object(model))
except AttributeError as e:
# May get typing special forms that don't have __qualname__ attribute
# These are not going to be models
if "__qualname__" in str(e):
return False
raise
if key not in self.models:

@@ -519,0 +526,0 @@ try:

# erdantic Changelog
## v1.0.2 (2024-04-11)
- Fixed `AttributeError` when adding a model that has a field annotated with certain typing special forms like `Any`, `Literal`, or `TypeVar` instances. ([Issue #114](https://github.com/drivendataorg/erdantic/issues/114), [PR #115](https://github.com/drivendataorg/erdantic/pull/115))
## v1.0.1 (2024-04-10)

@@ -4,0 +8,0 @@

+1
-1
Metadata-Version: 2.3
Name: erdantic
Version: 1.0.1
Version: 1.0.2
Summary: Entity relationship diagrams for Python data model classes like Pydantic.

@@ -5,0 +5,0 @@ Project-URL: Repository, https://github.com/drivendataorg/erdantic

@@ -7,3 +7,3 @@ [build-system]

name = "erdantic"
version = "1.0.1"
version = "1.0.2"
description = "Entity relationship diagrams for Python data model classes like Pydantic."

@@ -10,0 +10,0 @@ readme = "README.md"

@@ -7,3 +7,3 @@ import builtins

import sys
from typing import List, Optional
from typing import Any, AnyStr, List, Literal, Optional, TypeVar

@@ -16,2 +16,3 @@ if sys.version_info >= (3, 9):

import IPython.lib.pretty as IPython_pretty
import pydantic
import pytest

@@ -177,2 +178,17 @@ import rich

def test_model_with_typing_special_forms():
"""Models may have special forms in the leaf nodes and we should handle it."""
T = TypeVar("T")
class MyModel(pydantic.BaseModel):
any_field: Any
literal_field: Literal["a", "b", "c"]
type_var_field: T
anystr_field: AnyStr
diagram = EntityRelationshipDiagram()
diagram.add_model(MyModel)
def test_unsupported_forward_ref_resolution(monkeypatch):

@@ -179,0 +195,0 @@ """Plugin implementation does not do anything to resolve forward references."""

@@ -51,2 +51,5 @@ import typing

T = typing.TypeVar("T")
assert get_recursive_args(typing.Union[int, typing.List[T]]) == [int, T]
class SomeForwardRef: ...

@@ -53,0 +56,0 @@